From 61e7775fa75c7c1bdc29a6992c8c215897364600 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 27 May 2013 18:24:56 -0400 Subject: [PATCH] Remove hb-icu dependency from hb-icu-le shaper --- src/hb-icu-le.cc | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/hb-icu-le.cc b/src/hb-icu-le.cc index 114b427..634354e 100644 --- a/src/hb-icu-le.cc +++ b/src/hb-icu-le.cc @@ -30,10 +30,35 @@ #include "hb-icu-le/PortableFontInstance.h" -#include "layout/loengine.h" -#include "unicode/unistr.h" +#include +#include +#include +#include -#include "hb-icu.h" + +/* Duplicated here so we don't depend on hb-icu. */ + +static hb_script_t +_hb_icu_script_to_script (UScriptCode script) +{ + if (unlikely (script == USCRIPT_INVALID_CODE)) + return HB_SCRIPT_INVALID; + + return hb_script_from_string (uscript_getShortName (script), -1); +} + +static UScriptCode +_hb_icu_script_from_script (hb_script_t script) +{ + if (unlikely (script == HB_SCRIPT_INVALID)) + return USCRIPT_INVALID_CODE; + + for (unsigned int i = 0; i < USCRIPT_CODE_LIMIT; i++) + if (unlikely (_hb_icu_script_to_script ((UScriptCode) i) == script)) + return (UScriptCode) i; + + return USCRIPT_UNKNOWN; +} /* @@ -117,7 +142,7 @@ _hb_icu_le_shape (hb_shape_plan_t *shape_plan, unsigned int num_features) { LEFontInstance *font_instance = HB_SHAPER_DATA_GET (font); - le_int32 script_code = hb_icu_script_from_script (shape_plan->props.script); + le_int32 script_code = _hb_icu_script_from_script (shape_plan->props.script); le_int32 language_code = -1 /* TODO */; le_int32 typography_flags = 3; /* Needed for ligatures and kerning */ LEErrorCode status = LE_NO_ERROR; -- 2.7.4