summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/pfr/pfrcmap.c
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit38be0d13830efd2d98281c645c3a60afe05ffece (patch)
tree6ea73f3ec77f7d153333779883e8120f82820abe /src/3rdparty/freetype/src/pfr/pfrcmap.c
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'src/3rdparty/freetype/src/pfr/pfrcmap.c')
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrcmap.c167
1 files changed, 167 insertions, 0 deletions
diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.c b/src/3rdparty/freetype/src/pfr/pfrcmap.c
new file mode 100644
index 0000000000..d4656d1b5e
--- /dev/null
+++ b/src/3rdparty/freetype/src/pfr/pfrcmap.c
@@ -0,0 +1,167 @@
+/***************************************************************************/
+/* */
+/* pfrcmap.c */
+/* */
+/* FreeType PFR cmap handling (body). */
+/* */
+/* Copyright 2002, 2007 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include "pfrcmap.h"
+#include "pfrobjs.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "pfrerror.h"
+
+
+ FT_CALLBACK_DEF( FT_Error )
+ pfr_cmap_init( PFR_CMap cmap )
+ {
+ FT_Error error = PFR_Err_Ok;
+ PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap );
+
+
+ cmap->num_chars = face->phy_font.num_chars;
+ cmap->chars = face->phy_font.chars;
+
+ /* just for safety, check that the character entries are correctly */
+ /* sorted in increasing character code order */
+ {
+ FT_UInt n;
+
+
+ for ( n = 1; n < cmap->num_chars; n++ )
+ {
+ if ( cmap->chars[n - 1].char_code >= cmap->chars[n].char_code )
+ {
+ error = PFR_Err_Invalid_Table;
+ goto Exit;
+ }
+ }
+ }
+
+ Exit:
+ return error;
+ }
+
+
+ FT_CALLBACK_DEF( void )
+ pfr_cmap_done( PFR_CMap cmap )
+ {
+ cmap->chars = NULL;
+ cmap->num_chars = 0;
+ }
+
+
+ FT_CALLBACK_DEF( FT_UInt )
+ pfr_cmap_char_index( PFR_CMap cmap,
+ FT_UInt32 char_code )
+ {
+ FT_UInt min = 0;
+ FT_UInt max = cmap->num_chars;
+ FT_UInt mid;
+ PFR_Char gchar;
+
+
+ while ( min < max )
+ {
+ mid = min + ( max - min ) / 2;
+ gchar = cmap->chars + mid;
+
+ if ( gchar->char_code == char_code )
+ return mid + 1;
+
+ if ( gchar->char_code < char_code )
+ min = mid + 1;
+ else
+ max = mid;
+ }
+ return 0;
+ }
+
+
+ FT_CALLBACK_DEF( FT_UInt )
+ pfr_cmap_char_next( PFR_CMap cmap,
+ FT_UInt32 *pchar_code )
+ {
+ FT_UInt result = 0;
+ FT_UInt32 char_code = *pchar_code + 1;
+
+
+ Restart:
+ {
+ FT_UInt min = 0;
+ FT_UInt max = cmap->num_chars;
+ FT_UInt mid;
+ PFR_Char gchar;
+
+
+ while ( min < max )
+ {
+ mid = min + ( ( max - min ) >> 1 );
+ gchar = cmap->chars + mid;
+
+ if ( gchar->char_code == char_code )
+ {
+ result = mid;
+ if ( result != 0 )
+ {
+ result++;
+ goto Exit;
+ }
+
+ char_code++;
+ goto Restart;
+ }
+
+ if ( gchar->char_code < char_code )
+ min = mid+1;
+ else
+ max = mid;
+ }
+
+ /* we didn't find it, but we have a pair just above it */
+ char_code = 0;
+
+ if ( min < cmap->num_chars )
+ {
+ gchar = cmap->chars + min;
+ result = min;
+ if ( result != 0 )
+ {
+ result++;
+ char_code = gchar->char_code;
+ }
+ }
+ }
+
+ Exit:
+ *pchar_code = char_code;
+ return result;
+ }
+
+
+ FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
+ pfr_cmap_class_rec =
+ {
+ sizeof ( PFR_CMapRec ),
+
+ (FT_CMap_InitFunc) pfr_cmap_init,
+ (FT_CMap_DoneFunc) pfr_cmap_done,
+ (FT_CMap_CharIndexFunc)pfr_cmap_char_index,
+ (FT_CMap_CharNextFunc) pfr_cmap_char_next,
+
+ NULL, NULL, NULL, NULL, NULL
+ };
+
+
+/* END */