~alcinnz/harfbuzz-pure

728c810dc8f721d706ea80f2a07b39ca63d7872f — Adrian Cochrane 2 years ago 9f5f9d8
Fix build linking errors (mostly by upgrading GHC).

I'm now running on this on elementary OS Jolnir.
5 files changed, 8 insertions(+), 322 deletions(-)

M Data/Text/Glyphize/Buffer.hs
M Main.hs
D c-bits/hbc-buffer.c
D cabal.sandbox.config
M harfbuzz-pure.cabal
M Data/Text/Glyphize/Buffer.hs => Data/Text/Glyphize/Buffer.hs +5 -22
@@ 73,10 73,6 @@ data Buffer = Buffer {
    -- ^ The glyph number that replaces invisible characters in the
    -- shaping result. If set to zero (default), the glyph for the U+0020
    -- SPACE character is used. Otherwise, this value is used verbatim.
    notFoundGlyph :: Char,
    -- ^ the glyph number that replaces characters not found in the font during shaping.
    -- The not-found glyph defaults to zero, sometimes knows as the ".notdef" glyph.
    -- This API allows for differentiating the two.
    replacementCodepoint :: Char
    -- ^ the hb_codepoint_t that replaces invalid entries for a given encoding
    -- when adding text to buffer .


@@ 96,7 92,6 @@ defaultBuffer = Buffer {
        don'tInsertDottedCircle = False,
        clusterLevel = ClusterMonotoneGraphemes,
        invisibleGlyph = '\0',
        notFoundGlyph = '\0',
        replacementCodepoint = '\xFFFD'
    }



@@ 205,7 200,6 @@ freeze' buf = do
        ClusterMonotoneChars -> 1
        ClusterChars -> 2
    hb_buffer_set_invisible_glyph buffer $ c2w $ invisibleGlyph buf
    hb_buffer_set_not_found_glyph buffer $ c2w $ notFoundGlyph buf
    hb_buffer_set_replacement_codepoint buffer $ c2w $ replacementCodepoint buf
    case (contentType buf, direction buf, script buf, language buf) of
        (Just ContentTypeUnicode, Nothing, _, _) -> hb_buffer_guess_segment_properties buffer


@@ 221,14 215,10 @@ glyphInfos' buf' = alloca $ \length' -> do
    length <- peek length'
    forM [0..length - 1] $ peekElemOff arr
glyphsPos = unsafePerformIO . glyphsPos'
glyphsPos' buf' = do
    has_positions <- withForeignPtr buf' $ \buf'' -> hb_buffer_has_positions buf''
    if has_positions
    then alloca $ \length' -> do
        arr <- withForeignPtr buf' $ \buf'' -> hb_buffer_get_glyph_positions buf'' length'
        length <- peek length'
        forM [0..length-1] $ peekElemOff arr
    else return []
glyphsPos' buf' = alloca $ \length' -> do
      arr <- withForeignPtr buf' $ \buf'' -> hb_buffer_get_glyph_positions buf'' length'
      length <- peek length'
      forM [0..length-1] $ peekElemOff arr

thaw :: Buffer' -> Buffer
thaw = unsafePerformIO . thaw'


@@ 244,7 234,6 @@ thaw' buf' = do
    flags' <- getter hb_buffer_get_flags
    clusterLevel' <- getter hb_buffer_get_cluster_level
    invisibleGlyph' <- getter hb_buffer_get_invisible_glyph
    notFoundGlyph' <- getter hb_buffer_get_not_found_glyph
    replacementCodepoint' <- getter hb_buffer_get_replacement_codepoint
    return Buffer {
        text = Right $ LBS.fromStrict $ encodeUTF8 $ Prelude.map codepoint glyphInfos',


@@ 263,8 252,7 @@ thaw' buf' = do
            1 -> ClusterMonotoneChars
            2 -> ClusterChars
            _ -> ClusterMonotoneGraphemes,
        invisibleGlyph = w2c invisibleGlyph', notFoundGlyph = w2c notFoundGlyph',
        replacementCodepoint = w2c replacementCodepoint'
        invisibleGlyph = w2c invisibleGlyph', replacementCodepoint = w2c replacementCodepoint'
      }

foreign import ccall "hb_buffer_create" hb_buffer_create :: IO (Ptr Buffer'')


@@ 323,8 311,6 @@ foreign import ccall "hb_buffer_set_cluster_level" hb_buffer_set_cluster_level
    :: Ptr Buffer'' -> Int -> IO ()
foreign import ccall "hb_buffer_set_invisible_glyph" hb_buffer_set_invisible_glyph
    :: Ptr Buffer'' -> Word32 -> IO ()
foreign import ccall "hb_buffer_set_not_found_glyph" hb_buffer_set_not_found_glyph
    :: Ptr Buffer'' -> Word32 -> IO ()
foreign import ccall "hb_buffer_set_replacement_codepoint" hb_buffer_set_replacement_codepoint
    :: Ptr Buffer'' -> Word32 -> IO ()
foreign import ccall "hb_buffer_guess_segment_properties" hb_buffer_guess_segment_properties


@@ 349,12 335,9 @@ foreign import ccall "hb_buffer_get_cluster_level" hb_buffer_get_cluster_level
    :: Ptr Buffer'' -> IO Int
foreign import ccall "hb_buffer_get_glyph_infos" hb_buffer_get_glyph_infos
    :: Ptr Buffer'' -> Ptr Int -> IO (Ptr GlyphInfo)
foreign import ccall "hb_buffer_has_positions" hb_buffer_has_positions :: Ptr Buffer'' -> IO Bool
foreign import ccall "hb_buffer_get_glyph_positions" hb_buffer_get_glyph_positions
    :: Ptr Buffer'' -> Ptr Int -> IO (Ptr GlyphPos)
foreign import ccall "hb_buffer_get_invisible_glyph" hb_buffer_get_invisible_glyph
    :: Ptr Buffer'' -> IO Word32
foreign import ccall "hb_buffer_get_not_found_glyph" hb_buffer_get_not_found_glyph
    :: Ptr Buffer'' -> IO Word32
foreign import ccall "hb_buffer_get_replacement_codepoint" hb_buffer_get_replacement_codepoint
    :: Ptr Buffer'' -> IO Word32

M Main.hs => Main.hs +2 -2
@@ 7,6 7,6 @@ import "harfbuzz-pure" Data.Text.Glyphize.Buffer
main :: IO ()
main = do
    buf' <- freeze' defaultBuffer
    -- buf <- thaw' buf'
    print "Hello, world"
    buf <- thaw' buf'
    print buf
    -- TODO test I can shape text!

D c-bits/hbc-buffer.c => c-bits/hbc-buffer.c +0 -270
@@ 1,270 0,0 @@
#include <hb-buffer.h>

extern "C" {

hb_glyph_flags_t hbc_glyph_info_get_glyph_flags (const hb_glyph_info_t *info) {
    return hb_glyph_info_get_glyph_flags (info);
}

hb_bool_t hbc_segment_properties_equal (const hb_segment_properties_t *a,
			     const hb_segment_properties_t *b) {
    return hb_segment_properties_equal (a, b)
}

unsigned int hbc_segment_properties_hash (const hb_segment_properties_t *p) {
    return hb_segment_properties_hash (p);
}

void hbc_segment_properties_overlay (hb_segment_properties_t *p,
			       const hb_segment_properties_t *src) {
    return hb_segment_properties_overlay (p, src);
}

hb_buffer_t *hbc_buffer_create () {
    return hb_buffer_create ();
}

hb_buffer_t *hbc_buffer_create_similar (const hb_buffer_t *src) {
    return hb_buffer_create_similar (src);
}

void hbc_buffer_reset (hb_buffer_t *buffer) {
    return hb_buffer_reset (buffer);
}

hb_buffer_t * hbc_buffer_get_empty (void) {
    return hb_buffer_get_empty ();
}

hb_buffer_t *hbc_buffer_reference (hb_buffer_t *buffer) {
    return hb_buffer_reference (buffer);
}

void hbc_buffer_destroy (hb_buffer_t *buffer) {
    return hb_buffer_destroy (buffer);
}

hb_bool_t hbc_buffer_set_user_data (hb_buffer_t        *buffer,
			 hb_user_data_key_t *key,
			 void *              data,
			 hb_destroy_func_t   destroy,
			 hb_bool_t           replace) {
    return hb_buffer_set_user_data (buffer, key, data, destroy, replace);
}

void * hbc_buffer_get_user_data (hb_buffer_t        *buffer,
			 hb_user_data_key_t *key) {
    return hb_buffer_get_user_data (buffer, key);
}

void hb_buffer_set_content_type (hb_buffer_t              *buffer,
			    hb_buffer_content_type_t  content_type) {
    return hb_buffer_set_content_type (buffer, content_type);
}

hb_buffer_content_type_t hb_buffer_get_content_type (hb_buffer_t *buffer) {
    return hb_buffer_get_content_type (buffer);
}

void hbc_buffer_set_unicode_funcs (hb_buffer_t        *buffer,
			     hb_unicode_funcs_t *unicode_funcs) {
    return hb_buffer_set_unicode_funcs (buffer, unicode_funcs);
}

hb_unicode_funcs_t *hbc_buffer_get_unicode_funcs (hb_buffer_t* buffer) {
    return hb_buffer_get_unicode_funcs (buffer);
}

void hbc_buffer_set_direction (hb_buffer_t    *buffer,
			 hb_direction_t  direction) {
    return hb_buffer_set_direction (buffer, direction);
}

hb_direction_t hbc_buffer_get_direction (hb_buffer_t *buffer) {
    return hb_buffer_get_direction (buffer);
}

void hbc_buffer_set_script (hb_buffer_t *buffer,
		      hb_script_t  script) {
    return hb_buffer_set_script (*buffer, script);
}

hb_script_t hbc_buffer_get_script (hb_buffer_t *buffer) {
    return hb_buffer_get_script (buffer);
}

void hbc_buffer_set_language (hb_buffer_t   *buffer,
			hb_language_t  language) {
    return hb_buffer_set_language (buffer, language);
}

hb_language_t hbc_buffer_get_language (hb_buffer_t *buffer) {
    return hb_buffer_get_language (buffer);
}

void hbc_buffer_set_segment_properties (hb_buffer_t *buffer,
				  const hb_segment_properties_t *props) {
    return hb_buffer_set_segment_properties (buffer, props);
}

void hbc_buffer_get_segment_properties (hb_buffer_t *buffer,
				  hb_segment_properties_t *props) {
    return hb_buffer_get_segment_properties (buffer, props);
}

void hbc_buffer_guess_segment_properties (hb_buffer_t *buffer) {
    return hb_buffer_guess_segment_properties ();
}

void hbc_buffer_set_flags (hb_buffer_t       *buffer,
		     hb_buffer_flags_t  flags) {
    return hb_buffer_set_flags (buffer, flags);
}

hb_buffer_flags_t hbc_buffer_get_flags (hb_buffer_t *buffer) {
    return hb_buffer_get_flags (buffer);
}

void hbc_buffer_set_cluster_level (hb_buffer_t               *buffer,
			     hb_buffer_cluster_level_t  cluster_level) {
    return hb_buffer_set_cluster_level (buffer, cluster_level);
}

hb_buffer_cluster_level_t hbc_buffer_get_cluster_level (hb_buffer_t *buffer) {
    return hb_buffer_get_cluster_level (buffer);
}

void hbc_buffer_set_replacement_codepoint (hb_buffer_t    *buffer,
				     hb_codepoint_t  replacement) {
    return hb_buffer_set_replacement_codepoint (buffer, replacement);
}

hb_codepoint_t hbc_buffer_get_replacement_codepoint (hb_buffer_t    *buffer) {
    return hb_buffer_get_replacement_codepoint (buffer);
}

void hbc_buffer_set_invisible_glyph (hb_buffer_t    *buffer,
			       hb_codepoint_t  invisible) {
    return hb_buffer_set_invisible_glyph (*buffer, invisible);
}

hb_codepoint_t hbc_buffer_get_invisible_glyph (hb_buffer_t    *buffer) {
    return hb_buffer_get_invisible_glyph (buffer);
}

void hbc_buffer_set_not_found_glyph (hb_buffer_t    *buffer,
			       hb_codepoint_t  not_found) {
    return hb_buffer_set_not_found_glyph (buffer, not_found);
}

hb_codepoint_t hb_buffer_get_not_found_glyph (hb_buffer_t    *buffer) {
    return hb_buffer_get_not_found_glyph (buffer);
}

void hbc_buffer_clear_contents (hb_buffer_t *buffer) {
    return hb_buffer_clear_contents (buffer);
}

hb_bool_t hbc_buffer_pre_allocate (hb_buffer_t  *buffer,
			unsigned int  size) {
    return hb_buffer_pre_allocate (buffer, size);
}

hb_bool_t hbc_buffer_allocation_successful (hb_buffer_t  *buffer) {
    return hb_buffer_allocation_successful (buffer);
}

void hbc_buffer_reverse (hb_buffer_t *buffer) {
    return hb_buffer_reverse (buffer);
}

void hbc_buffer_reverse_range (hb_buffer_t *buffer,
			 unsigned int start, unsigned int end) {
    return hb_buffer_reverse_range (buffer, start, end);
}

void hbc_buffer_reverse_clusters (hb_buffer_t *buffer) {
    return hb_buffer_reverse_clusters (buffer);
}

void hbc_buffer_add (hb_buffer_t    *buffer,
	       hb_codepoint_t  codepoint,
	       unsigned int    cluster) {
    hb_buffer_add (buffer, codepoint, cluster);
}

void hbc_buffer_add_utf8 (hb_buffer_t  *buffer,
		    const char   *text,
		    int           text_length,
		    unsigned int  item_offset,
		    int           item_length) {
    hb_buffer_add_utf8 (buffer, text, text_length, item_offset, item_length);
}

void hbc_buffer_add_utf16 (hb_buffer_t    *buffer,
		     const uint16_t *text,
		     int             text_length,
		     unsigned int    item_offset,
		     int             item_length) {
    hb_buffer_add_utf16 (buffer, text, text_length, item_offset, item_length);
}

void hbc_buffer_add_utf32 (hb_buffer_t    *buffer,
		     const uint32_t *text,
		     int             text_length,
		     unsigned int    item_offset,
		     int             item_length) {
    hb_buffer_add_utf32 (buffer, text, text_length, item_offset, item_length);
}

void hbc_buffer_add_latin1 (hb_buffer_t   *buffer,
		      const uint8_t *text,
		      int            text_length,
		      unsigned int   item_offset,
		      int            item_length) {
    hb_buffer_add_latin1 (buffer, text, text_length, item_offset, item_length);
}

void hbc_buffer_add_codepoints (hb_buffer_t          *buffer,
			  const hb_codepoint_t *text,
			  int                   text_length,
			  unsigned int          item_offset,
			  int                   item_length) {
    hb_buffer_add_codepoints (buffer, text, text_length, item_offset, item_length);
}

void hbc_buffer_append (hb_buffer_t *buffer,
		  const hb_buffer_t *source,
		  unsigned int start,
		  unsigned int end) {
    hb_buffer_append (buffer, source, start, end);
}

hb_bool_t hbc_buffer_set_length (hb_buffer_t  *buffer,
		      unsigned int  length) {
    return hb_buffer_set_length (buffer, length);
}

unsigned int hbc_buffer_get_length (hb_buffer_t *buffer) {
    return hb_buffer_get_length (buffer);
}

hb_glyph_info_t *hbc_buffer_get_glyph_infos (hb_buffer_t  *buffer,
			   unsigned int *length) {
    return hb_buffer_get_glyph_infos (buffer, length);
}

hb_glyph_position_t *hbc_buffer_get_glyph_positions (hb_buffer_t  *buffer,
			       unsigned int *length) {
    return hb_buffer_get_glyph_positions (buffer, length);
}

hb_bool_t hbc_buffer_has_positions (hb_buffer_t  *buffer) {
    return hb_buffer_has_positions (buffer);
}

void hbc_buffer_normalize_glyphs (hb_buffer_t *buffer) {
    hb_buffer_normalize_glyphs (buffer);
}

}

D cabal.sandbox.config => cabal.sandbox.config +0 -26
@@ 1,26 0,0 @@
-- This is a Cabal package environment file.
-- THIS FILE IS AUTO-GENERATED. DO NOT EDIT DIRECTLY.
-- Please create a 'cabal.config' file in the same directory
-- if you want to change the default settings for this sandbox.


local-repo: /home/alcinnz/Projects/browser-engine/harfbuzz-pure/.cabal-sandbox/packages
logs-dir: /home/alcinnz/Projects/browser-engine/harfbuzz-pure/.cabal-sandbox/logs
world-file: /home/alcinnz/Projects/browser-engine/harfbuzz-pure/.cabal-sandbox/world
user-install: False
package-db: /home/alcinnz/Projects/browser-engine/harfbuzz-pure/.cabal-sandbox/x86_64-linux-ghc-8.0.2-packages.conf.d
build-summary: /home/alcinnz/Projects/browser-engine/harfbuzz-pure/.cabal-sandbox/logs/build.log

install-dirs
  prefix: /home/alcinnz/Projects/browser-engine/harfbuzz-pure/.cabal-sandbox
  bindir: $prefix/bin
  libdir: $prefix/lib
  libsubdir: $abi/$libname
  dynlibdir: $libdir/$abi
  libexecdir: $prefix/libexec
  datadir: $prefix/share
  datasubdir: $abi/$pkgid
  docdir: $datadir/doc/$abi/$pkgid
  htmldir: $docdir/html
  haddockdir: $htmldir
  sysconfdir: $prefix/etc

M harfbuzz-pure.cabal => harfbuzz-pure.cabal +1 -2
@@ 61,9 61,8 @@ library
  
  -- Other library packages from which modules are imported.
  build-depends:       base >=4.9 && <5, bytestring, text, text-short, utf8-light
--                       , freetype2 >= 0.2
                       , freetype2 >= 0.2
  pkgconfig-depends:   harfbuzz
  cxx-sources:         c-bits/hbc-buffer.c
  
  -- Directories containing source files.
  -- hs-source-dirs: