Home | History | Annotate | Download | only in fxge
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #include "../thirdparties/freetype/ft2build.h"
      8 #include "../thirdparties/freetype/freetype/freetype.h"
      9 #include "../thirdparties/freetype/freetype/ftoutln.h"
     10 #include "../thirdparties/freetype/freetype/ftmm.h"
     11 #include "../thirdparties/freetype/freetype/internal/ftobjs.h"
     12 #include "../thirdparties/freetype/freetype/tttables.h"
     13 #ifdef __cplusplus
     14 extern "C" {
     15 #endif
     16 #define FXFT_ENCODING_UNICODE FT_ENCODING_UNICODE
     17 #define FXFT_ENCODING_ADOBE_STANDARD FT_ENCODING_ADOBE_STANDARD
     18 #define FXFT_ENCODING_ADOBE_EXPERT FT_ENCODING_ADOBE_EXPERT
     19 #define FXFT_ENCODING_ADOBE_LATIN_1 FT_ENCODING_ADOBE_LATIN_1
     20 #define FXFT_ENCODING_APPLE_ROMAN FT_ENCODING_APPLE_ROMAN
     21 #define FXFT_ENCODING_ADOBE_CUSTOM FT_ENCODING_ADOBE_CUSTOM
     22 #define FXFT_ENCODING_MS_SYMBOL FT_ENCODING_MS_SYMBOL
     23 #define FXFT_ENCODING_GB2312 FT_ENCODING_GB2312
     24 #define FXFT_ENCODING_BIG5 FT_ENCODING_BIG5
     25 #define FXFT_ENCODING_SJIS FT_ENCODING_SJIS
     26 #define FXFT_ENCODING_JOHAB FT_ENCODING_JOHAB
     27 #define FXFT_ENCODING_WANSUNG FT_ENCODING_WANSUNG
     28 #define FXFT_LOAD_NO_SCALE FT_LOAD_NO_SCALE
     29 #define FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
     30 #define FXFT_RENDER_MODE_LCD FT_RENDER_MODE_LCD
     31 #define FXFT_RENDER_MODE_MONO FT_RENDER_MODE_MONO
     32 #define FXFT_RENDER_MODE_NORMAL FT_RENDER_MODE_NORMAL
     33 #define FXFT_LOAD_IGNORE_TRANSFORM FT_LOAD_IGNORE_TRANSFORM
     34 #define FXFT_LOAD_NO_BITMAP FT_LOAD_NO_BITMAP
     35 #define FXFT_LOAD_NO_HINTING FT_LOAD_NO_HINTING
     36 #define FXFT_PIXEL_MODE_MONO FT_PIXEL_MODE_MONO
     37 #define FXFT_STYLE_FLAG_ITALIC FT_STYLE_FLAG_ITALIC
     38 #define FXFT_STYLE_FLAG_BOLD FT_STYLE_FLAG_BOLD
     39 #define FXFT_FACE_FLAG_SFNT FT_FACE_FLAG_SFNT
     40 #define FXFT_FACE_FLAG_TRICKY ( 1L << 13 )
     41 typedef FT_MM_Var*		FXFT_MM_Var;
     42 typedef FT_Bitmap*		FXFT_Bitmap;
     43 #define FXFT_Matrix		FT_Matrix
     44 #define FXFT_Vector		FT_Vector
     45 #define FXFT_Outline_Funcs FT_Outline_Funcs
     46 typedef FT_Open_Args	FXFT_Open_Args;
     47 typedef FT_StreamRec	FXFT_StreamRec;
     48 typedef FT_StreamRec*	FXFT_Stream;
     49 typedef FT_BBox			FXFT_BBox;
     50 typedef FT_Glyph		FXFT_Glyph;
     51 typedef FT_CharMap		FXFT_CharMap;
     52 #define FXFT_GLYPH_BBOX_PIXELS	FT_GLYPH_BBOX_PIXELS
     53 #define FXFT_Open_Face(library, args, index, face) \
     54     FT_Open_Face((FT_Library)(library), args, index, (FT_Face*)(face))
     55 #define FXFT_Done_Face(face) FT_Done_Face((FT_Face)(face))
     56 #define FXFT_Done_FreeType(library) FT_Done_FreeType((FT_Library)(library))
     57 #define FXFT_Init_FreeType(library) FT_Init_FreeType((FT_Library*)(library))
     58 #define FXFT_New_Memory_Face(library, base, size, index, face) \
     59     FT_New_Memory_Face((FT_Library)(library), base, size, index, (FT_Face*)(face))
     60 #define FXFT_New_Face(library, filename, index, face) \
     61     FT_New_Face((FT_Library)(library), filename, index, (FT_Face*)(face))
     62 #define FXFT_Get_Face_FreeType(face) ((FT_Face)face)->driver->root.library
     63 #define FXFT_Select_Charmap(face, encoding) FT_Select_Charmap((FT_Face)face, (FT_Encoding)encoding)
     64 #define FXFT_Set_Charmap(face, charmap) FT_Set_Charmap((FT_Face)face, (FT_CharMap)charmap)
     65 #define FXFT_Load_Glyph(face, glyph_index, flags) FT_Load_Glyph((FT_Face)face, glyph_index, flags)
     66 #define FXFT_Get_Char_Index(face, code) FT_Get_Char_Index((FT_Face)face, code)
     67 #define FXFT_Get_Glyph_Name(face, index, buffer, size) FT_Get_Glyph_Name((FT_Face)face, index, buffer, size)
     68 #define FXFT_Get_Name_Index(face, name) FT_Get_Name_Index((FT_Face)face, name)
     69 #define FXFT_Has_Glyph_Names(face)  (((FT_Face)face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES)
     70 #define FXFT_Get_Postscript_Name(face) FT_Get_Postscript_Name((FT_Face)face)
     71 #define FXFT_Load_Sfnt_Table(face, tag, offset, buffer, length) \
     72     FT_Load_Sfnt_Table((FT_Face)face, tag, offset, buffer, length)
     73 #define FXFT_Get_First_Char(face, glyph_index) FT_Get_First_Char((FT_Face)face, glyph_index)
     74 #define FXFT_Get_Next_Char(face, code, glyph_index) FT_Get_Next_Char((FT_Face)face, code, glyph_index)
     75 #define FXFT_Clear_Face_External_Stream(face) (((FT_Face)face)->face_flags&=~FT_FACE_FLAG_EXTERNAL_STREAM)
     76 #define FXFT_Get_Face_External_Stream(face) (((FT_Face)face)->face_flags&FT_FACE_FLAG_EXTERNAL_STREAM)
     77 #define FXFT_Is_Face_TT_OT(face) (((FT_Face)face)->face_flags&FT_FACE_FLAG_SFNT)
     78 #define FXFT_Is_Face_Tricky(face) (((FT_Face)face)->face_flags&FXFT_FACE_FLAG_TRICKY)
     79 #define FXFT_Is_Face_fixedwidth(face) (((FT_Face)face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH)
     80 #define FXFT_Get_Face_Stream_Base(face) ((FT_Face)face)->stream->base
     81 #define FXFT_Get_Face_Stream_Size(face) ((FT_Face)face)->stream->size
     82 #define FXFT_Get_Face_Family_Name(face) ((FT_Face)face)->family_name
     83 #define FXFT_Get_Face_Style_Name(face) ((FT_Face)face)->style_name
     84 #define FXFT_Get_Face_Numfaces(face) ((FT_Face)face)->num_faces
     85 #define FXFT_Get_Face_Faceindex(face) ((FT_Face)face)->face_index
     86 #define FXFT_Is_Face_Italic(face) (((FT_Face)face)->style_flags&FT_STYLE_FLAG_ITALIC)
     87 #define FXFT_Is_Face_Bold(face) (((FT_Face)face)->style_flags&FT_STYLE_FLAG_BOLD)
     88 #define FXFT_Get_Face_Charmaps(face) ((FT_Face)face)->charmaps
     89 #define FXFT_Get_Glyph_HoriBearingX(face) ((FT_Face)face)->glyph->metrics.horiBearingX
     90 #define FXFT_Get_Glyph_HoriBearingY(face) ((FT_Face)face)->glyph->metrics.horiBearingY
     91 #define FXFT_Get_Glyph_Width(face) ((FT_Face)face)->glyph->metrics.width
     92 #define FXFT_Get_Glyph_Height(face) ((FT_Face)face)->glyph->metrics.height
     93 #define FXFT_Get_Face_CharmapCount(face) ((FT_Face)face)->num_charmaps
     94 #define FXFT_Get_Charmap_Encoding(charmap) ((FT_CharMap)charmap)->encoding
     95 #define FXFT_Get_Face_Charmap(face) ((FT_Face)face)->charmap
     96 #define FXFT_Get_Charmap_PlatformID(charmap) ((FT_CharMap)charmap)->platform_id
     97 #define FXFT_Get_Charmap_EncodingID(charmap) ((FT_CharMap)charmap)->encoding_id
     98 #define FXFT_Get_Face_UnitsPerEM(face) ((FT_Face)face)->units_per_EM
     99 #define FXFT_Get_Face_xMin(face) ((FT_Face)face)->bbox.xMin
    100 #define FXFT_Get_Face_xMax(face) ((FT_Face)face)->bbox.xMax
    101 #define FXFT_Get_Face_yMin(face) ((FT_Face)face)->bbox.yMin
    102 #define FXFT_Get_Face_yMax(face) ((FT_Face)face)->bbox.yMax
    103 #define FXFT_Get_Face_Height(face) ((FT_Face)face)->height
    104 #define FXFT_Get_Face_UnderLineThickness(face) ((FT_Face)face)->underline_thickness
    105 #define FXFT_Get_Face_UnderLinePosition(face) ((FT_Face)face)->underline_position
    106 #define FXFT_Get_Face_MaxAdvanceWidth(face) ((FT_Face)face)->max_advance_width
    107 #define FXFT_Get_Face_Ascender(face) ((FT_Face)face)->ascender
    108 #define FXFT_Get_Face_Descender(face) ((FT_Face)face)->descender
    109 #define FXFT_Get_Glyph_HoriAdvance(face) ((FT_Face)face)->glyph->metrics.horiAdvance
    110 #define FXFT_Get_MM_Axis(var, index) &((FT_MM_Var*)var)->axis[index]
    111 #define FXFT_Get_MM_Axis_Min(axis) ((FT_Var_Axis*)axis)->minimum
    112 #define FXFT_Get_MM_Axis_Max(axis) ((FT_Var_Axis*)axis)->maximum
    113 #define FXFT_Get_MM_Axis_Def(axis) ((FT_Var_Axis*)axis)->def
    114 #define FXFT_Get_Face_Internal_Flag(face) ((FT_Face)face)->internal->transform_flags
    115 #define FXFT_Set_Face_Internal_Flag(face, flag) (((FT_Face)face)->internal->transform_flags = flag)
    116 #define FXFT_Alloc(library, size) ((FT_Library)library)->memory->alloc(((FT_Library)library)->memory, size)
    117 #define FXFT_Free(face, p) ((FT_Face)face)->memory->free(((FT_Face)face)->memory, p)
    118 #define FXFT_Get_Glyph_Outline(face) &((FT_Face)face)->glyph->outline
    119 #define FXFT_Get_Outline_Bbox(outline, cbox)  FT_Outline_Get_CBox(outline, cbox)
    120 #define FXFT_Render_Glyph(face, mode) FT_Render_Glyph(((FT_Face)face)->glyph, (enum FT_Render_Mode_)mode)
    121 #define FXFT_Get_MM_Var(face, p) FT_Get_MM_Var((FT_Face)face, p)
    122 #define FXFT_Set_MM_Design_Coordinates(face, n, p) FT_Set_MM_Design_Coordinates((FT_Face)face, n, p)
    123 #define FXFT_Set_Pixel_Sizes(face, w, h) FT_Set_Pixel_Sizes((FT_Face)face, w, h)
    124 #define FXFT_Set_Transform(face, m, d) FT_Set_Transform((FT_Face)face, m, d)
    125 #define FXFT_Outline_Embolden(outline, s) FT_Outline_Embolden(outline, s)
    126 #define FXFT_Get_Glyph_Bitmap(face) &((FT_Face)face)->glyph->bitmap
    127 #define FXFT_Get_Bitmap_Width(bitmap) ((FT_Bitmap*)bitmap)->width
    128 #define FXFT_Get_Bitmap_Rows(bitmap) ((FT_Bitmap*)bitmap)->rows
    129 #define FXFT_Get_Bitmap_PixelMode(bitmap) ((FT_Bitmap*)bitmap)->pixel_mode
    130 #define FXFT_Get_Bitmap_Pitch(bitmap) ((FT_Bitmap*)bitmap)->pitch
    131 #define FXFT_Get_Bitmap_Buffer(bitmap) ((FT_Bitmap*)bitmap)->buffer
    132 #define FXFT_Get_Glyph_BitmapLeft(face) ((FT_Face)face)->glyph->bitmap_left
    133 #define FXFT_Get_Glyph_BitmapTop(face) ((FT_Face)face)->glyph->bitmap_top
    134 #define FXFT_Outline_Decompose(outline, funcs, params) FT_Outline_Decompose(outline, funcs, params)
    135 #define FXFT_Set_Char_Size(face, char_width, char_height, horz_resolution, vert_resolution) FT_Set_Char_Size(face, char_width, char_height, horz_resolution, vert_resolution)
    136 #define FXFT_Get_Glyph(slot, aglyph) FT_Get_Glyph(slot, aglyph)
    137 #define FXFT_Glyph_Get_CBox(glyph, bbox_mode, acbox) FT_Glyph_Get_CBox(glyph, bbox_mode, acbox)
    138 #define FXFT_Done_Glyph(glyph)	FT_Done_Glyph(glyph)
    139 #define FXFT_Library_SetLcdFilter(library, filter) FT_Library_SetLcdFilter((FT_Library)(library), filter)
    140 int FXFT_unicode_from_adobe_name(const char* name);
    141 void FXFT_adobe_name_from_unicode(char* name, unsigned int unicode);
    142 #ifdef __cplusplus
    143 };
    144 #endif
    145