summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/pfr/pfrcmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/pfr/pfrcmap.c')
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrcmap.c105
1 files changed, 58 insertions, 47 deletions
diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.c b/src/3rdparty/freetype/src/pfr/pfrcmap.c
index 60643780a1..08fe41d54e 100644
--- a/src/3rdparty/freetype/src/pfr/pfrcmap.c
+++ b/src/3rdparty/freetype/src/pfr/pfrcmap.c
@@ -1,23 +1,22 @@
-/***************************************************************************/
-/* */
-/* pfrcmap.c */
-/* */
-/* FreeType PFR cmap handling (body). */
-/* */
-/* Copyright 2002-2018 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 <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
+/****************************************************************************
+ *
+ * pfrcmap.c
+ *
+ * FreeType PFR cmap handling (body).
+ *
+ * Copyright (C) 2002-2023 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 <freetype/internal/ftdebug.h>
#include "pfrcmap.h"
#include "pfrobjs.h"
@@ -25,17 +24,18 @@
FT_CALLBACK_DEF( FT_Error )
- pfr_cmap_init( PFR_CMap cmap,
+ pfr_cmap_init( FT_CMap cmap, /* PFR_CMap */
FT_Pointer pointer )
{
- FT_Error error = FT_Err_Ok;
- PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap );
+ PFR_CMap pfrcmap = (PFR_CMap)cmap;
+ FT_Error error = FT_Err_Ok;
+ PFR_Face face = (PFR_Face)FT_CMAP_FACE( cmap );
FT_UNUSED( pointer );
- cmap->num_chars = face->phy_font.num_chars;
- cmap->chars = face->phy_font.chars;
+ pfrcmap->num_chars = face->phy_font.num_chars;
+ pfrcmap->chars = face->phy_font.chars;
/* just for safety, check that the character entries are correctly */
/* sorted in increasing character code order */
@@ -43,9 +43,9 @@
FT_UInt n;
- for ( n = 1; n < cmap->num_chars; n++ )
+ for ( n = 1; n < pfrcmap->num_chars; n++ )
{
- if ( cmap->chars[n - 1].char_code >= cmap->chars[n].char_code )
+ if ( pfrcmap->chars[n - 1].char_code >= pfrcmap->chars[n].char_code )
{
error = FT_THROW( Invalid_Table );
goto Exit;
@@ -59,29 +59,30 @@
FT_CALLBACK_DEF( void )
- pfr_cmap_done( PFR_CMap cmap )
+ pfr_cmap_done( FT_CMap cmap ) /* PFR_CMap */
{
- cmap->chars = NULL;
- cmap->num_chars = 0;
+ PFR_CMap pfrcmap = (PFR_CMap)cmap;
+
+
+ pfrcmap->chars = NULL;
+ pfrcmap->num_chars = 0;
}
FT_CALLBACK_DEF( FT_UInt )
- pfr_cmap_char_index( PFR_CMap cmap,
+ pfr_cmap_char_index( FT_CMap cmap, /* PFR_CMap */
FT_UInt32 char_code )
{
- FT_UInt min = 0;
- FT_UInt max = cmap->num_chars;
+ PFR_CMap pfrcmap = (PFR_CMap)cmap;
+ FT_UInt min = 0;
+ FT_UInt max = pfrcmap->num_chars;
+ FT_UInt mid = min + ( max - min ) / 2;
+ PFR_Char gchar;
while ( min < max )
{
- PFR_Char gchar;
- FT_UInt mid;
-
-
- mid = min + ( max - min ) / 2;
- gchar = cmap->chars + mid;
+ gchar = pfrcmap->chars + mid;
if ( gchar->char_code == char_code )
return mid + 1;
@@ -90,15 +91,21 @@
min = mid + 1;
else
max = mid;
+
+ /* reasonable prediction in a continuous block */
+ mid += char_code - gchar->char_code;
+ if ( mid >= max || mid < min )
+ mid = min + ( max - min ) / 2;
}
return 0;
}
- FT_CALLBACK_DEF( FT_UInt32 )
- pfr_cmap_char_next( PFR_CMap cmap,
+ FT_CALLBACK_DEF( FT_UInt )
+ pfr_cmap_char_next( FT_CMap cmap, /* PFR_CMap */
FT_UInt32 *pchar_code )
{
+ PFR_CMap pfrcmap = (PFR_CMap)cmap;
FT_UInt result = 0;
FT_UInt32 char_code = *pchar_code + 1;
@@ -106,15 +113,14 @@
Restart:
{
FT_UInt min = 0;
- FT_UInt max = cmap->num_chars;
- FT_UInt mid;
+ FT_UInt max = pfrcmap->num_chars;
+ FT_UInt mid = min + ( max - min ) / 2;
PFR_Char gchar;
while ( min < max )
{
- mid = min + ( ( max - min ) >> 1 );
- gchar = cmap->chars + mid;
+ gchar = pfrcmap->chars + mid;
if ( gchar->char_code == char_code )
{
@@ -133,14 +139,19 @@
min = mid + 1;
else
max = mid;
+
+ /* reasonable prediction in a continuous block */
+ mid += char_code - gchar->char_code;
+ if ( mid >= max || mid < min )
+ mid = min + ( max - min ) / 2;
}
/* we didn't find it, but we have a pair just above it */
char_code = 0;
- if ( min < cmap->num_chars )
+ if ( min < pfrcmap->num_chars )
{
- gchar = cmap->chars + min;
+ gchar = pfrcmap->chars + min;
result = min;
if ( result != 0 )
{