diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-10-26 07:13:09 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-10-26 07:13:09 +0000 |
commit | 74cc05c672add53f566ac385f117008e8c4b3eda (patch) | |
tree | ce973a7d2e4814a20d52a55b1a2131d1515e9911 /Build/source/libs/icu/icu-50.1/samples/layout | |
parent | 6439fb8917718c4d620170e1459a1d9e7ab3c441 (diff) |
icu 50.1 (50_rc)
git-svn-id: svn://tug.org/texlive/trunk@28087 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/icu/icu-50.1/samples/layout')
55 files changed, 6079 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.GDI b/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.GDI new file mode 100644 index 00000000000..c01c40f3d5a --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.GDI @@ -0,0 +1,11 @@ +# Copyright (C) 2001-2010, International Business Machines +# Corporation and others. All Rights Reserved. +# +# This is a sample FontMap file for Windows. +# Fonts are specified by font name, as shown +# in the "Fonts" folder. + + DEVANAGARI: Raghindi + THAI: Courier MonoThai + DEFAULT: Code2000 + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.Gnome b/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.Gnome new file mode 100644 index 00000000000..1f57bb4814d --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.Gnome @@ -0,0 +1,8 @@ +# Copyright (C) 2001-2005, International Business Machines +# Corporation and others. All Rights Reserved. +# This is a sample FontMap file for Linux. +# Fonts are specified by file names. + + DEVANAGARI: raghu.ttf + THAI: angsd___.ttf + DEFAULT: CODE2000.TTF diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.cpp new file mode 100644 index 00000000000..1510b29b2da --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.cpp @@ -0,0 +1,287 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2006, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#include "unicode/utypes.h" +#include "unicode/uscript.h" + +#include "layout/LETypes.h" +#include "layout/LEScripts.h" +#include "layout/LEFontInstance.h" + +#include "GUISupport.h" +#include "FontMap.h" + +FontMap::FontMap(const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status) + : fPointSize(pointSize), fFontCount(0), fAscent(0), fDescent(0), fLeading(0), fGUISupport(guiSupport) +{ + le_int32 defaultFont = -1, i, script; + le_bool haveFonts = FALSE; + +/**/ + for (i = 0; i < scriptCodeCount; i += 1) { + fFontIndices[i] = -1; + fFontNames[i] = NULL; + fFontInstances[i] = NULL; + } + /**/ + + if (LE_FAILURE(status)) { + return; + } + + char *c, *scriptName, *fontName, *line, buffer[BUFFER_SIZE]; + FILE *file; + + file = fopen(fileName, "r"); + + if (file == NULL) { + sprintf(errorMessage, "Could not open the font map file: %s.", fileName); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + while (fgets(buffer, BUFFER_SIZE, file) != NULL) { + UScriptCode scriptCode; + UErrorCode scriptStatus = U_ZERO_ERROR; + + line = strip(buffer); + if (line[0] == '#' || line[0] == 0) { + continue; + } + + c = strchr(line, ':'); + c[0] = 0; + + fontName = strip(&c[1]); + scriptName = strip(line); + + if (strcmp(scriptName, "DEFAULT") == 0) { + defaultFont = getFontIndex(fontName); + haveFonts = TRUE; + continue; + } + + le_int32 fillCount = uscript_getCode(scriptName, &scriptCode, 1, &scriptStatus); + + if (U_FAILURE(scriptStatus) || fillCount <= 0 || + scriptStatus == U_USING_FALLBACK_WARNING || scriptStatus == U_USING_DEFAULT_WARNING) { + sprintf(errorMessage, "The script name %s is invalid.", line); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + continue; + } + + script = (le_int32) scriptCode; + + if (fFontIndices[script] >= 0) { + // FIXME: complain that this is a duplicate entry and bail (?) + fFontIndices[script] = -1; + } + + fFontIndices[script] = getFontIndex(fontName); + haveFonts = TRUE; + } + + if (defaultFont >= 0) { + for (script = 0; script < scriptCodeCount; script += 1) { + if (fFontIndices[script] < 0) { + fFontIndices[script] = defaultFont; + } + } + } + + if (! haveFonts) { + sprintf(errorMessage, "The font map file %s does not contain any valid scripts.", fileName); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + status = LE_ILLEGAL_ARGUMENT_ERROR; + } + + fclose(file); +} + +FontMap::~FontMap() +{ + le_int32 font; + + for (font = 0; font < fFontCount; font += 1) { + if (fFontNames[font] != NULL) { + delete[] (char *) fFontNames[font]; + } + } + + for (font = 0; font < fFontCount; font += 1) { + if (fFontInstances[font] != NULL) { + delete fFontInstances[font]; + } + } +} + +le_int32 FontMap::getFontIndex(const char *fontName) +{ + le_int32 index; + + for (index = 0; index < fFontCount; index += 1) { + if (strcmp(fontName, fFontNames[index]) == 0) { + return index; + } + } + + if (fFontCount < (le_int32) scriptCodeCount) { + index = fFontCount++; + } else { + // The font name table is full. Since there can + // only be scriptCodeCount fonts in use at once, + // there should be at least one that's not being + // referenced; find it and resue it's index. + + for (index = 0; index < fFontCount; index += 1) { + le_int32 script; + + for (script = 0; script < scriptCodeCount; script += 1) { + if (fFontIndices[script] == index) { + break; + } + } + + if (script >= scriptCodeCount) { + break; + } + } + } + + if (index >= scriptCodeCount) { + return -1; + } + + le_int32 len = strlen(fontName); + char *s = new char[len + 1]; + + fFontNames[index] = strcpy(s, fontName); + return index; +} + +char *FontMap::strip(char *s) +{ + le_int32 start, end, len; + + start = 0; + len = strlen(s); + + while (start < len && isspace(s[start])) { + start += 1; + } + + end = len - 1; + + while (end > start && isspace(s[end])) { + end -= 1; + } + + if (end < len) { + s[end + 1] = '\0'; + } + + return &s[start]; +} + +const LEFontInstance *FontMap::getScriptFont(le_int32 scriptCode, LEErrorCode &status) +{ + if (LE_FAILURE(status)) { + return NULL; + } + + if (scriptCode <= -1 || scriptCode >= scriptCodeCount) { + status = LE_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } + + + le_int32 fontIndex = fFontIndices[scriptCode]; + + if (fontIndex < 0) { + sprintf(errorMessage, "No font was set for script %s", uscript_getName((UScriptCode) scriptCode)); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return NULL; + } + + if (fFontInstances[fontIndex] == NULL) { + fFontInstances[fontIndex] = openFont(fFontNames[fontIndex], fPointSize, status); + + if (LE_FAILURE(status)) { + sprintf(errorMessage, "Could not open font file %s", fFontNames[fontIndex]); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + return NULL; + } + } + + return fFontInstances[fontIndex]; +} + +le_int32 FontMap::getAscent() const +{ + if (fAscent <= 0) { + ((FontMap *) this)->getMaxMetrics(); + } + + return fAscent; +} + +le_int32 FontMap::getDescent() const +{ + if (fDescent <= 0) { + ((FontMap *) this)->getMaxMetrics(); + } + + return fDescent; +} + +le_int32 FontMap::getLeading() const +{ + if (fLeading <= 0) { + ((FontMap *) this)->getMaxMetrics(); + } + + return fLeading; +} + +void FontMap::getMaxMetrics() +{ + for (le_int32 i = 0; i < fFontCount; i += 1) { + LEErrorCode status = LE_NO_ERROR; + le_int32 ascent, descent, leading; + + if (fFontInstances[i] == NULL) { + fFontInstances[i] = openFont(fFontNames[i], fPointSize, status); + + if (LE_FAILURE(status)) { + continue; + } + } + + ascent = fFontInstances[i]->getAscent(); + descent = fFontInstances[i]->getDescent(); + leading = fFontInstances[i]->getLeading(); + + if (ascent > fAscent) { + fAscent = ascent; + } + + if (descent > fDescent) { + fDescent = descent; + } + + if (leading > fLeading) { + fLeading = leading; + } + } +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.h b/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.h new file mode 100644 index 00000000000..fa80ebfd090 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/FontMap.h @@ -0,0 +1,66 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2003, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#ifndef __FONTMAP_H +#define __FONTMAP_H + +#include "layout/LETypes.h" +#include "layout/LEScripts.h" +#include "layout/LEFontInstance.h" + +#include "GUISupport.h" + +#define BUFFER_SIZE 128 + +class FontMap +{ +public: + FontMap(const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status); + + virtual ~FontMap(); + + virtual const LEFontInstance *getScriptFont(le_int32 scriptCode, LEErrorCode &status); + + virtual le_int16 getPointSize() const; + + virtual le_int32 getAscent() const; + + virtual le_int32 getDescent() const; + + virtual le_int32 getLeading() const; + +protected: + virtual const LEFontInstance *openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status) = 0; + + char errorMessage[256]; + +private: + static char *strip(char *s); + le_int32 getFontIndex(const char *fontName); + void getMaxMetrics(); + + le_int16 fPointSize; + le_int32 fFontCount; + + le_int32 fAscent; + le_int32 fDescent; + le_int32 fLeading; + + GUISupport *fGUISupport; + + const LEFontInstance *fFontInstances[scriptCodeCount]; + const char *fFontNames[scriptCodeCount]; + le_int32 fFontIndices[scriptCodeCount]; +}; + +inline le_int16 FontMap::getPointSize() const +{ + return fPointSize; +} + +#endif + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/FontTableCache.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/FontTableCache.cpp new file mode 100644 index 00000000000..c6547be2f31 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/FontTableCache.cpp @@ -0,0 +1,91 @@ +/* + ********************************************************************** + * Copyright (C) 2003 - 2008, International Business Machines + * Corporation and others. All Rights Reserved. + ********************************************************************** + */ + +#include "layout/LETypes.h" + +#include "FontTableCache.h" + +#define TABLE_CACHE_INIT 5 +#define TABLE_CACHE_GROW 5 + +struct FontTableCacheEntry +{ + LETag tag; + const void *table; +}; + +FontTableCache::FontTableCache() + : fTableCacheCurr(0), fTableCacheSize(TABLE_CACHE_INIT) +{ + fTableCache = LE_NEW_ARRAY(FontTableCacheEntry, fTableCacheSize); + + if (fTableCache == NULL) { + fTableCacheSize = 0; + return; + } + + for (int i = 0; i < fTableCacheSize; i += 1) { + fTableCache[i].tag = 0; + fTableCache[i].table = NULL; + } +} + +FontTableCache::~FontTableCache() +{ + for (int i = fTableCacheCurr - 1; i >= 0; i -= 1) { + freeFontTable(fTableCache[i].table); + + fTableCache[i].tag = 0; + fTableCache[i].table = NULL; + } + + fTableCacheCurr = 0; + + LE_DELETE_ARRAY(fTableCache); + fTableCache = NULL; +} + +void FontTableCache::freeFontTable(const void *table) const +{ + LE_DELETE_ARRAY(table); +} + +const void *FontTableCache::find(LETag tableTag) const +{ + for (int i = 0; i < fTableCacheCurr; i += 1) { + if (fTableCache[i].tag == tableTag) { + return fTableCache[i].table; + } + } + + const void *table = readFontTable(tableTag); + + ((FontTableCache *) this)->add(tableTag, table); + + return table; +} + +void FontTableCache::add(LETag tableTag, const void *table) +{ + if (fTableCacheCurr >= fTableCacheSize) { + le_int32 newSize = fTableCacheSize + TABLE_CACHE_GROW; + + fTableCache = (FontTableCacheEntry *) LE_GROW_ARRAY(fTableCache, newSize); + + for (le_int32 i = fTableCacheSize; i < newSize; i += 1) { + fTableCache[i].tag = 0; + fTableCache[i].table = NULL; + } + + fTableCacheSize = newSize; + } + + fTableCache[fTableCacheCurr].tag = tableTag; + fTableCache[fTableCacheCurr].table = table; + + fTableCacheCurr += 1; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/FontTableCache.h b/Build/source/libs/icu/icu-50.1/samples/layout/FontTableCache.h new file mode 100644 index 00000000000..333e90cd7d7 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/FontTableCache.h @@ -0,0 +1,39 @@ +/* + ********************************************************************** + * Copyright (C) 2003-2008, International Business Machines + * Corporation and others. All Rights Reserved. + ********************************************************************** + */ + +#ifndef __FONTTABLECACHE_H + +#define __FONTTABLECACHE_H + +#include "layout/LETypes.h" + +struct FontTableCacheEntry; + +class FontTableCache +{ +public: + FontTableCache(); + + virtual ~FontTableCache(); + + const void *find(LETag tableTag) const; + +protected: + virtual const void *readFontTable(LETag tableTag) const = 0; + virtual void freeFontTable(const void *table) const; + +private: + + void add(LETag tableTag, const void *table); + + FontTableCacheEntry *fTableCache; + le_int32 fTableCacheCurr; + le_int32 fTableCacheSize; +}; + +#endif + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontInstance.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontInstance.cpp new file mode 100644 index 00000000000..5e94e5d2ffb --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontInstance.cpp @@ -0,0 +1,402 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2008, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GDIFontInstance.cpp + * + * created on: 08/09/2000 + * created by: Eric R. Mader + */ + +#include <windows.h> + +#include "layout/LETypes.h" +#include "layout/LESwaps.h" +#include "layout/LEFontInstance.h" + +#include "GDIFontInstance.h" +#include "sfnt.h" +#include "cmaps.h" + +GDISurface::GDISurface(HDC theHDC) + : fHdc(theHDC), fCurrentFont(NULL) +{ + // nothing else to do +} + +GDISurface::~GDISurface() +{ + // nothing to do +} + +void GDISurface::setHDC(HDC theHDC) +{ + fHdc = theHDC; + fCurrentFont = NULL; +} + +void GDISurface::setFont(const GDIFontInstance *font) +{ +#if 0 + if (fCurrentFont != font) { + fCurrentFont = font; + SelectObject(fHdc, font->getFont()); + } +#else + SelectObject(fHdc, font->getFont()); +#endif +} + +void GDISurface::drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, const float *positions, + le_int32 x, le_int32 y, le_int32 width, le_int32 height) +{ + TTGlyphID *ttGlyphs = LE_NEW_ARRAY(TTGlyphID, count); + le_int32 *dx = LE_NEW_ARRAY(le_int32, count); + float *ps = LE_NEW_ARRAY(float, count * 2 + 2); + le_int32 out = 0; + RECT clip; + + clip.top = 0; + clip.left = 0; + clip.bottom = height; + clip.right = width; + + for (le_int32 g = 0; g < count; g += 1) { + TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyphs[g]); + + if (ttGlyph < 0xFFFE) { + ttGlyphs[out] = ttGlyph; + dx[out] = (le_int32) (positions[g * 2 + 2] - positions[g * 2]); + ps[out * 2] = positions[g * 2]; + ps[out * 2 + 1] = positions[g * 2 + 1]; + out += 1; + } + } + + le_int32 dyStart, dyEnd; + + setFont((GDIFontInstance *) font); + + dyStart = dyEnd = 0; + + while (dyEnd < out) { + float yOffset = ps[dyStart * 2 + 1]; + float xOffset = ps[dyStart * 2]; + + while (dyEnd < out && yOffset == ps[dyEnd * 2 + 1]) { + dyEnd += 1; + } + + ExtTextOut(fHdc, x + (le_int32) xOffset, y + (le_int32) yOffset - font->getAscent(), ETO_CLIPPED | ETO_GLYPH_INDEX, &clip, + (LPCWSTR) &ttGlyphs[dyStart], dyEnd - dyStart, (INT *) &dx[dyStart]); + + dyStart = dyEnd; + } + + LE_DELETE_ARRAY(ps); + LE_DELETE_ARRAY(dx); + LE_DELETE_ARRAY(ttGlyphs); +} + +GDIFontInstance::GDIFontInstance(GDISurface *surface, TCHAR *faceName, le_int16 pointSize, LEErrorCode &status) + : FontTableCache(), fSurface(surface), fFont(NULL), + fPointSize(pointSize), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0), + fDeviceScaleX(1), fDeviceScaleY(1), fMapper(NULL) +{ + LOGFONT lf; + FLOAT dpiX, dpiY; + POINT pt; + OUTLINETEXTMETRIC otm; + HDC hdc = surface->getHDC(); + + if (LE_FAILURE(status)) { + return; + } + + SaveDC(hdc); + + SetGraphicsMode(hdc, GM_ADVANCED); + ModifyWorldTransform(hdc, NULL, MWT_IDENTITY); + SetViewportOrgEx(hdc, 0, 0, NULL); + SetWindowOrgEx(hdc, 0, 0, NULL); + + dpiX = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSX); + dpiY = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSY); + +#if 1 + pt.x = (int) (pointSize * dpiX / 72); + pt.y = (int) (pointSize * dpiY / 72); + + DPtoLP(hdc, &pt, 1); +#else + pt.x = pt.y = pointSize; +#endif + + lf.lfHeight = - pt.y; + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfWeight = 0; + lf.lfItalic = 0; + lf.lfUnderline = 0; + lf.lfStrikeOut = 0; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfOutPrecision = 0; + lf.lfClipPrecision = 0; + lf.lfQuality = 0; + lf.lfPitchAndFamily = 0; + + lstrcpy(lf.lfFaceName, faceName); + + fFont = CreateFontIndirect(&lf); + + if (fFont == NULL) { + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + SelectObject(hdc, fFont); + + UINT ret = GetOutlineTextMetrics(hdc, sizeof otm, &otm); + + if (ret == 0) { + status = LE_MISSING_FONT_TABLE_ERROR; + goto restore; + } + + fUnitsPerEM = otm.otmEMSquare; + fAscent = otm.otmTextMetrics.tmAscent; + fDescent = otm.otmTextMetrics.tmDescent; + fLeading = otm.otmTextMetrics.tmExternalLeading; + + status = initMapper(); + + if (LE_FAILURE(status)) { + goto restore; + } + +#if 0 + status = initFontTableCache(); +#endif + +restore: + RestoreDC(hdc, -1); +} + +GDIFontInstance::GDIFontInstance(GDISurface *surface, const char *faceName, le_int16 pointSize, LEErrorCode &status) + : FontTableCache(), fSurface(surface), fFont(NULL), + fPointSize(pointSize), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0), + fDeviceScaleX(1), fDeviceScaleY(1), fMapper(NULL) +{ + LOGFONTA lf; + FLOAT dpiX, dpiY; + POINT pt; + OUTLINETEXTMETRIC otm; + HDC hdc = surface->getHDC(); + + if (LE_FAILURE(status)) { + return; + } + + SaveDC(hdc); + + SetGraphicsMode(hdc, GM_ADVANCED); + ModifyWorldTransform(hdc, NULL, MWT_IDENTITY); + SetViewportOrgEx(hdc, 0, 0, NULL); + SetWindowOrgEx(hdc, 0, 0, NULL); + + dpiX = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSX); + dpiY = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSY); + + fDeviceScaleX = dpiX / 72; + fDeviceScaleY = dpiY / 72; + +#if 1 + pt.x = (int) (pointSize * fDeviceScaleX); + pt.y = (int) (pointSize * fDeviceScaleY); + + DPtoLP(hdc, &pt, 1); +#else + pt.x = pt.y = pointSize; +#endif + + lf.lfHeight = - pt.y; + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfWeight = 0; + lf.lfItalic = 0; + lf.lfUnderline = 0; + lf.lfStrikeOut = 0; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfOutPrecision = 0; + lf.lfClipPrecision = 0; + lf.lfQuality = 0; + lf.lfPitchAndFamily = 0; + + strcpy(lf.lfFaceName, faceName); + + fFont = CreateFontIndirectA(&lf); + + if (fFont == NULL) { + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + SelectObject(hdc, fFont); + + UINT ret = GetOutlineTextMetrics(hdc, sizeof otm, &otm); + + if (ret != 0) { + fUnitsPerEM = otm.otmEMSquare; + fAscent = otm.otmTextMetrics.tmAscent; + fDescent = otm.otmTextMetrics.tmDescent; + fLeading = otm.otmTextMetrics.tmExternalLeading; + } else { + const HEADTable *headTable = NULL; + const HHEATable *hheaTable = NULL; + + // read unitsPerEm from 'head' table + headTable = (const HEADTable *) readFontTable(LE_HEAD_TABLE_TAG); + + if (headTable == NULL) { + status = LE_MISSING_FONT_TABLE_ERROR; + goto restore; + } + + fUnitsPerEM = SWAPW(headTable->unitsPerEm); + freeFontTable((const void *)headTable); + + hheaTable = (HHEATable *) readFontTable(LE_HHEA_TABLE_TAG); + + if (hheaTable == NULL) { + status = LE_MISSING_FONT_TABLE_ERROR; + goto restore; + } + + fAscent = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->ascent)); + fDescent = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->descent)); + fLeading = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->lineGap)); + + freeFontTable((const void *) hheaTable); + } + + status = initMapper(); + + if (LE_FAILURE(status)) { + goto restore; + } + +#if 0 + status = initFontTableCache(); +#endif + +restore: + RestoreDC(hdc, -1); +} + +GDIFontInstance::~GDIFontInstance() +{ +#if 0 + flushFontTableCache(); + delete[] fTableCache; +#endif + + if (fFont != NULL) { + // FIXME: call RemoveObject first? + DeleteObject(fFont); + } + + delete fMapper; + fMapper = NULL; +} + +LEErrorCode GDIFontInstance::initMapper() +{ + LETag cmapTag = LE_CMAP_TABLE_TAG; + const CMAPTable *cmap = (const CMAPTable *) readFontTable(cmapTag); + + if (cmap == NULL) { + return LE_MISSING_FONT_TABLE_ERROR; + } + + fMapper = CMAPMapper::createUnicodeMapper(cmap); + + if (fMapper == NULL) { + return LE_MISSING_FONT_TABLE_ERROR; + } + + return LE_NO_ERROR; +} + +const void *GDIFontInstance::getFontTable(LETag tableTag) const +{ + return FontTableCache::find(tableTag); +} + +const void *GDIFontInstance::readFontTable(LETag tableTag) const +{ + fSurface->setFont(this); + + HDC hdc = fSurface->getHDC(); + DWORD stag = SWAPL(tableTag); + DWORD len = GetFontData(hdc, stag, 0, NULL, 0); + void *result = NULL; + + if (len != GDI_ERROR) { + result = LE_NEW_ARRAY(char, len); + GetFontData(hdc, stag, 0, result, len); + } + + return result; +} + +void GDIFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const +{ + advance.fX = 0; + advance.fY = 0; + + if (glyph == 0xFFFE || glyph == 0xFFFF) { + return; + } + + + GLYPHMETRICS metrics; + DWORD result; + MAT2 identity = {{0, 1}, {0, 0}, {0, 0}, {0, 1}}; + HDC hdc = fSurface->getHDC(); + + fSurface->setFont(this); + + result = GetGlyphOutline(hdc, glyph, GGO_GLYPH_INDEX | GGO_METRICS, &metrics, 0, NULL, &identity); + + if (result == GDI_ERROR) { + return; + } + + advance.fX = metrics.gmCellIncX; + return; +} + +le_bool GDIFontInstance::getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const +{ +#if 0 + hsFixedPoint2 pt; + le_bool result; + + result = fFontInstance->getGlyphPoint(glyph, pointNumber, pt); + + if (result) { + point.fX = xUnitsToPoints(pt.fX); + point.fY = yUnitsToPoints(pt.fY); + } + + return result; +#else + return FALSE; +#endif +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontInstance.h b/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontInstance.h new file mode 100644 index 00000000000..7b677e77262 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontInstance.h @@ -0,0 +1,156 @@ + +/* + ******************************************************************************* + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GDIFontInstance.h + * + * created on: 08/09/2000 + * created by: Eric R. Mader + */ + +#ifndef __GDIFONTINSTANCE_H +#define __GDIFONTINSTANCE_H + +#include <windows.h> + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" +#include "RenderingSurface.h" +#include "FontTableCache.h" +#include "cmaps.h" + +class GDIFontInstance; + +class GDISurface : public RenderingSurface +{ +public: + GDISurface(HDC theHDC); + virtual ~GDISurface(); + + virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height); + + void setFont(const GDIFontInstance *font); + HDC getHDC() const; + void setHDC(HDC theHDC); + +private: + HDC fHdc; + const GDIFontInstance *fCurrentFont; +}; + +inline HDC GDISurface::getHDC() const +{ + return fHdc; +} + +class GDIFontInstance : public LEFontInstance, protected FontTableCache +{ +protected: + GDISurface *fSurface; + HFONT fFont; + + le_int32 fPointSize; + le_int32 fUnitsPerEM; + le_int32 fAscent; + le_int32 fDescent; + le_int32 fLeading; + + float fDeviceScaleX; + float fDeviceScaleY; + + CMAPMapper *fMapper; + + virtual const void *readFontTable(LETag tableTag) const; + + virtual LEErrorCode initMapper(); + +public: + GDIFontInstance(GDISurface *surface, TCHAR *faceName, le_int16 pointSize, LEErrorCode &status); + GDIFontInstance(GDISurface *surface, const char *faceName, le_int16 pointSize, LEErrorCode &status); + //GDIFontInstance(GDISurface *surface, le_int16 pointSize); + + virtual ~GDIFontInstance(); + + HFONT getFont() const; + + virtual const void *getFontTable(LETag tableTag) const; + + virtual le_int32 getUnitsPerEM() const; + + virtual le_int32 getAscent() const; + + virtual le_int32 getDescent() const; + + virtual le_int32 getLeading() const; + + virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; + + virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; + + virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; + + float getXPixelsPerEm() const; + + float getYPixelsPerEm() const; + + float getScaleFactorX() const; + + float getScaleFactorY() const; +}; + +inline HFONT GDIFontInstance::getFont() const +{ + return fFont; +} + +inline le_int32 GDIFontInstance::getUnitsPerEM() const +{ + return fUnitsPerEM; +} + +inline le_int32 GDIFontInstance::getAscent() const +{ + return fAscent; +} + +inline le_int32 GDIFontInstance::getDescent() const +{ + return fDescent; +} + +inline le_int32 GDIFontInstance::getLeading() const +{ + return fLeading; +} + +inline LEGlyphID GDIFontInstance::mapCharToGlyph(LEUnicode32 ch) const +{ + return fMapper->unicodeToGlyph(ch); +} + +inline float GDIFontInstance::getXPixelsPerEm() const +{ + return (float) fPointSize; +} + +inline float GDIFontInstance::getYPixelsPerEm() const +{ + return (float) fPointSize; +} + +inline float GDIFontInstance::getScaleFactorX() const +{ + return fDeviceScaleX; +} + +inline float GDIFontInstance::getScaleFactorY() const +{ + return fDeviceScaleY; +} + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontMap.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontMap.cpp new file mode 100644 index 00000000000..480bbe0eb8a --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontMap.cpp @@ -0,0 +1,39 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2003, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#include <windows.h> + +#include "layout/LEFontInstance.h" + +#include "GDIFontInstance.h" + +#include "GUISupport.h" +#include "FontMap.h" +#include "GDIFontMap.h" + +GDIFontMap::GDIFontMap(GDISurface *surface, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status) + : FontMap(fileName, pointSize, guiSupport, status), fSurface(surface) +{ + // nothing to do? +} + +GDIFontMap::~GDIFontMap() +{ + // anything? +} + +const LEFontInstance *GDIFontMap::openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status) +{ + LEFontInstance *result = new GDIFontInstance(fSurface, fontName, pointSize, status); + + if (LE_FAILURE(status)) { + delete result; + result = NULL; + } + + return result; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontMap.h b/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontMap.h new file mode 100644 index 00000000000..e92f47f0c0c --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GDIFontMap.h @@ -0,0 +1,38 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2003, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#ifndef __GDIFONTMAP_H +#define __GDIFONTMAP_H + +#include <windows.h> + +#include "unicode/uscript.h" + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +#include "FontMap.h" +#include "GUISupport.h" +#include "GDIFontInstance.h" + +#define BUFFER_SIZE 128 + +class GDIFontMap : public FontMap +{ +public: + GDIFontMap(GDISurface *surface, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status); + + virtual ~GDIFontMap(); + +protected: + virtual const LEFontInstance *openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status); + +private: + GDISurface *fSurface; +}; + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GDIGUISupport.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/GDIGUISupport.cpp new file mode 100644 index 00000000000..9f55ffed61e --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GDIGUISupport.cpp @@ -0,0 +1,22 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2001, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GDIGUISupport.h + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#include <windows.h> + +#include "GDIGUISupport.h" + +void GDIGUISupport::postErrorMessage(const char *message, const char *title) +{ + MessageBoxA(NULL, message, title, MB_ICONERROR); +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GDIGUISupport.h b/Build/source/libs/icu/icu-50.1/samples/layout/GDIGUISupport.h new file mode 100644 index 00000000000..ad4c7143b5a --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GDIGUISupport.h @@ -0,0 +1,28 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2005, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GDIGUISupport.h + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#ifndef __GDIGUISUPPORT_H +#define __GDIGUISUPPORT_H + +#include "GUISupport.h" + +class GDIGUISupport : public GUISupport +{ +public: + GDIGUISupport() {}; + virtual ~GDIGUISupport() {}; + + virtual void postErrorMessage(const char *message, const char *title); +}; + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GUISupport.h b/Build/source/libs/icu/icu-50.1/samples/layout/GUISupport.h new file mode 100644 index 00000000000..f41b7cec91d --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GUISupport.h @@ -0,0 +1,26 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2005, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GUISupport.h + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#ifndef __GUISUPPORT_H +#define __GUISUPPORT_H + +class GUISupport +{ +public: + GUISupport() {}; + virtual ~GUISupport() {}; + + virtual void postErrorMessage(const char *message, const char *title) = 0; +}; + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontInstance.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontInstance.cpp new file mode 100644 index 00000000000..2a5c307b8f7 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontInstance.cpp @@ -0,0 +1,201 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GnomeFontInstance.cpp + * + * created on: 08/30/2001 + * created by: Eric R. Mader + */ + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_GLYPH_H +#include FT_RENDER_H +#include FT_TRUETYPE_TABLES_H +#include <cairo.h> +#include <cairo-ft.h> + +#include "layout/LETypes.h" +#include "layout/LESwaps.h" + +#include "GnomeFontInstance.h" +#include "sfnt.h" +#include "cmaps.h" + +GnomeSurface::GnomeSurface(GtkWidget *theWidget) + : fWidget(theWidget) +{ + fCairo = gdk_cairo_create(fWidget->window); +} + +GnomeSurface::~GnomeSurface() +{ + cairo_destroy(fCairo); +} + +void GnomeSurface::drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 /*width*/, le_int32 /*height*/) +{ + GnomeFontInstance *gFont = (GnomeFontInstance *) font; + + gFont->rasterizeGlyphs(fCairo, glyphs, count, positions, x, y); +} + +GnomeFontInstance::GnomeFontInstance(FT_Library engine, const char *fontPathName, le_int16 pointSize, LEErrorCode &status) + : FontTableCache(), fPointSize(pointSize), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0), + fDeviceScaleX(1), fDeviceScaleY(1), fMapper(NULL) +{ + FT_Error error; + + fFace = NULL; + fCairoFace = NULL; + + error = FT_New_Face(engine, fontPathName, 0, &fFace); + + if (error != 0) { + printf("OOPS! Got error code %d\n", error); + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + // FIXME: what about the display resolution? + fDeviceScaleX = ((float) 96) / 72; + fDeviceScaleY = ((float) 96) / 72; + + error = FT_Set_Char_Size(fFace, 0, pointSize << 6, 92, 92); + + fCairoFace = cairo_ft_font_face_create_for_ft_face(fFace, 0); + + fUnitsPerEM = fFace->units_per_EM; + + fAscent = (le_int32) (yUnitsToPoints(fFace->ascender) * fDeviceScaleY); + fDescent = (le_int32) -(yUnitsToPoints(fFace->descender) * fDeviceScaleY); + fLeading = (le_int32) (yUnitsToPoints(fFace->height) * fDeviceScaleY) - fAscent - fDescent; + + // printf("Face = %s, unitsPerEM = %d, ascent = %d, descent = %d\n", fontPathName, fUnitsPerEM, fAscent, fDescent); + + if (error != 0) { + status = LE_MEMORY_ALLOCATION_ERROR; + return; + } + + status = initMapper(); +} + +GnomeFontInstance::~GnomeFontInstance() +{ + cairo_font_face_destroy(fCairoFace); + + if (fFace != NULL) { + FT_Done_Face(fFace); + } +} + +LEErrorCode GnomeFontInstance::initMapper() +{ + LETag cmapTag = LE_CMAP_TABLE_TAG; + const CMAPTable *cmap = (const CMAPTable *) readFontTable(cmapTag); + + if (cmap == NULL) { + return LE_MISSING_FONT_TABLE_ERROR; + } + + fMapper = CMAPMapper::createUnicodeMapper(cmap); + + if (fMapper == NULL) { + return LE_MISSING_FONT_TABLE_ERROR; + } + + return LE_NO_ERROR; +} + +const void *GnomeFontInstance::getFontTable(LETag tableTag) const +{ + return FontTableCache::find(tableTag); +} + +const void *GnomeFontInstance::readFontTable(LETag tableTag) const +{ + FT_ULong len = 0; + FT_Byte *result = NULL; + + FT_Load_Sfnt_Table(fFace, tableTag, 0, NULL, &len); + + if (len > 0) { + result = LE_NEW_ARRAY(FT_Byte, len); + FT_Load_Sfnt_Table(fFace, tableTag, 0, result, &len); + } + + return result; +} + +void GnomeFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const +{ + advance.fX = 0; + advance.fY = 0; + + if (glyph >= 0xFFFE) { + return; + } + + FT_Error error; + + error = FT_Load_Glyph(fFace, glyph, FT_LOAD_DEFAULT); + + if (error != 0) { + return; + } + + advance.fX = fFace->glyph->metrics.horiAdvance >> 6; + return; +} + +le_bool GnomeFontInstance::getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const +{ + FT_Error error; + + error = FT_Load_Glyph(fFace, glyph, FT_LOAD_DEFAULT); + + if (error != 0) { + return FALSE; + } + + if (pointNumber >= fFace->glyph->outline.n_points) { + return FALSE; + } + + point.fX = fFace->glyph->outline.points[pointNumber].x >> 6; + point.fY = fFace->glyph->outline.points[pointNumber].y >> 6; + + return TRUE; +} + +void GnomeFontInstance::rasterizeGlyphs(cairo_t *cairo, const LEGlyphID *glyphs, le_int32 glyphCount, const float *positions, + le_int32 x, le_int32 y) const +{ + cairo_glyph_t *glyph_t = LE_NEW_ARRAY(cairo_glyph_t, glyphCount); + le_int32 in, out; + + for (in = 0, out = 0; in < glyphCount; in += 1) { + TTGlyphID glyph = LE_GET_GLYPH(glyphs[in]); + + if (glyph < 0xFFFE) { + glyph_t[out].index = glyph; + glyph_t[out].x = x + positions[in*2]; + glyph_t[out].y = y + positions[in*2 + 1]; + + out += 1; + } + } + + cairo_set_font_face(cairo, fCairoFace); + cairo_set_font_size(cairo, getXPixelsPerEm() * getScaleFactorX()); + cairo_show_glyphs(cairo, glyph_t, out); + + LE_DELETE_ARRAY(glyph_t); +} diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontInstance.h b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontInstance.h new file mode 100644 index 00000000000..4af393804cd --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontInstance.h @@ -0,0 +1,166 @@ + +/* + ******************************************************************************* + * + * Copyright (C) 1999-2006, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GnomeFontInstance.h + * + * created on: 08/30/2001 + * created by: Eric R. Mader + */ + +#ifndef __GNOMEFONTINSTANCE_H +#define __GNOMEFONTINSTANCE_H + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_GLYPH_H +#include <cairo.h> + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +#include "RenderingSurface.h" +#include "FontTableCache.h" +#include "cmaps.h" + +class GnomeSurface : public RenderingSurface +{ +public: + GnomeSurface(GtkWidget *theWidget); + virtual ~GnomeSurface(); + + virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height); + + GtkWidget *getWidget() const; + void setWidget(GtkWidget *theWidget); + +private: + GtkWidget *fWidget; + cairo_t *fCairo; +}; + +class GnomeFontInstance : public LEFontInstance, protected FontTableCache +{ + protected: + FT_Face fFace; +// FT_Glyph fGlyph; + + cairo_font_face_t *fCairoFace; + + le_int32 fPointSize; + le_int32 fUnitsPerEM; + le_int32 fAscent; + le_int32 fDescent; + le_int32 fLeading; + + float fDeviceScaleX; + float fDeviceScaleY; + + CMAPMapper *fMapper; + + virtual const void *readFontTable(LETag tableTag) const; + + virtual LEErrorCode initMapper(); + + public: + GnomeFontInstance(FT_Library engine, const char *fontPathName, le_int16 pointSize, LEErrorCode &status); + + virtual ~GnomeFontInstance(); + + virtual const void *getFontTable(LETag tableTag) const; + + virtual le_int32 getUnitsPerEM() const; + + virtual le_int32 getAscent() const; + + virtual le_int32 getDescent() const; + + virtual le_int32 getLeading() const; + + virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; + + virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; + + virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; + + float getXPixelsPerEm() const; + + float getYPixelsPerEm() const; + + float getScaleFactorX() const; + + float getScaleFactorY() const; + + void rasterizeGlyphs(cairo_t *cairo, const LEGlyphID *glyphs, le_int32 glyphCount, const float *positions, + le_int32 x, le_int32 y) const; +}; + +inline GtkWidget *GnomeSurface::getWidget() const +{ + return fWidget; +} + +inline void GnomeSurface::setWidget(GtkWidget *theWidget) +{ + fWidget = theWidget; +} + +/* +inline FT_Instance GnomeFontInstance::getFont() const +{ + return fInstance; +} +*/ + +inline le_int32 GnomeFontInstance::getUnitsPerEM() const +{ + return fUnitsPerEM; +} + +inline le_int32 GnomeFontInstance::getAscent() const +{ + return fAscent; +} + +inline le_int32 GnomeFontInstance::getDescent() const +{ + return fDescent; +} + +inline le_int32 GnomeFontInstance::getLeading() const +{ + return fLeading; +} + +inline LEGlyphID GnomeFontInstance::mapCharToGlyph(LEUnicode32 ch) const +{ + return fMapper->unicodeToGlyph(ch); +} + +inline float GnomeFontInstance::getXPixelsPerEm() const +{ + return (float) fPointSize; +} + +inline float GnomeFontInstance::getYPixelsPerEm() const +{ + return (float) fPointSize; +} + +inline float GnomeFontInstance::getScaleFactorX() const +{ + return fDeviceScaleX; +} + +inline float GnomeFontInstance::getScaleFactorY() const +{ + return fDeviceScaleY; +} + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontMap.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontMap.cpp new file mode 100644 index 00000000000..6a23b305627 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontMap.cpp @@ -0,0 +1,41 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2006, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#include <stdio.h> + +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "layout/LEFontInstance.h" +#include "GnomeFontInstance.h" + +#include "GUISupport.h" +#include "FontMap.h" +#include "GnomeFontMap.h" + +GnomeFontMap::GnomeFontMap(FT_Library engine, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status) + : FontMap(fileName, pointSize, guiSupport, status), fEngine(engine) +{ + // nothing to do? +} + +GnomeFontMap::~GnomeFontMap() +{ + // anything? +} + +const LEFontInstance *GnomeFontMap::openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status) +{ + LEFontInstance *result = new GnomeFontInstance(fEngine, fontName, pointSize, status); + + if (LE_FAILURE(status)) { + delete result; + result = NULL; + } + + return result; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontMap.h b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontMap.h new file mode 100644 index 00000000000..a068b2b558f --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeFontMap.h @@ -0,0 +1,38 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2006, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#ifndef __GNOMEFONTMAP_H +#define __GNOMEFONTMAP_H + +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "unicode/uscript.h" + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +#include "GUISupport.h" +#include "FontMap.h" + +#define BUFFER_SIZE 128 + +class GnomeFontMap : public FontMap +{ + public: + GnomeFontMap(FT_Library engine, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status); + + virtual ~GnomeFontMap(); + + protected: + virtual const LEFontInstance *openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status); + + private: + FT_Library fEngine; +}; + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GnomeGUISupport.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeGUISupport.cpp new file mode 100644 index 00000000000..2835b616a01 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeGUISupport.cpp @@ -0,0 +1,37 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2001, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GnomeGUISupport.cpp + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#if 1 +#include <gnome.h> +#else +#include <stdio.h> +#endif + +#include "GnomeGUISupport.h" + +void GnomeGUISupport::postErrorMessage(const char *message, const char *title) +{ +#if 1 + gchar *s; + GtkWidget *error; + + s = g_strconcat(title, ":\n", message, NULL); + error = gnome_error_dialog(s); + gtk_widget_show(error); + g_free(s); +#else + fprintf(stderr, "%s: %s\n", title, message); +#endif +} + + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/GnomeGUISupport.h b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeGUISupport.h new file mode 100644 index 00000000000..e88ef128a14 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/GnomeGUISupport.h @@ -0,0 +1,28 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2005, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GnomeGUISupport.h + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#ifndef __GNOMEGUISUPPORT_H +#define __GNOMEGUISUPPORT_H + +#include "GUISupport.h" + +class GnomeGUISupport : public GUISupport +{ +public: + GnomeGUISupport() {}; + virtual ~GnomeGUISupport() {}; + + virtual void postErrorMessage(const char *message, const char *title); +}; + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/LayoutSample.rc b/Build/source/libs/icu/icu-50.1/samples/layout/LayoutSample.rc new file mode 100644 index 00000000000..9b0d3df88cc --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/LayoutSample.rc @@ -0,0 +1,115 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +/* +******************************************************************************* +* +* Copyright (C) 2002-2003, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ +#include <winresrc.h> + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +LAYOUTSAMPLE MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New Sample\tCtrl+N", IDM_FILE_NEWSAMPLE + MENUITEM "&Open...\tCtrl+O", IDM_FILE_OPEN + MENUITEM SEPARATOR + MENUITEM "&Close\tCtrl+W", IDM_FILE_CLOSE + MENUITEM "E&xit\tCtrl+Q", IDM_FILE_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About Layout Sample...", IDM_HELP_ABOUTLAYOUTSAMPLE + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +LAYOUTSAMPLE ACCELERATORS DISCARDABLE +BEGIN + "N", IDM_FILE_NEWSAMPLE, VIRTKEY, CONTROL, NOINVERT + "O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT + "Q", IDM_FILE_EXIT, VIRTKEY, CONTROL, NOINVERT + "W", IDM_FILE_CLOSE, VIRTKEY, CONTROL, NOINVERT +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "/*\r\n" + "*******************************************************************************\r\n" + "*\r\n" + "* Copyright (C) 2002-2003, International Business Machines\r\n" + "* Corporation and others. All Rights Reserved.\r\n" + "*\r\n" + "*******************************************************************************\r\n" + "*/\r\n" + "#include <winresrc.h>\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/Makefile.in b/Build/source/libs/icu/icu-50.1/samples/layout/Makefile.in new file mode 100644 index 00000000000..4beb90f3468 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/Makefile.in @@ -0,0 +1,107 @@ +## Makefile.in for ICU - samples/layout +## Copyright (c) 2001-2011, International Business Machines Corporation and +## others. All Rights Reserved. + +## Source directory information +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ + +top_builddir = ../.. + +include $(top_builddir)/icudefs.mk + +## Platform-specific setup +include @platform_make_fragment@ + +## Build directory information +subdir = samples/layout + +## Extra files to remove for 'make clean' +CLEANFILES = *~ $(DEPS) + +## Target information +TARGET = gnomelayout +CTARGET = cgnomelayout + +CPPFLAGS += -DLE_USE_CMEMORY `pkg-config --cflags libgnomeui-2.0 freetype2 cairo` -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/layoutex -I$(top_srcdir)/layout -I$(top_srcdir) -g + +LIBS = $(LIBICULX) $(LIBICULE) $(LIBICUUC) $(LIBICUI18N) @LIBS@ @LIB_M@ `pkg-config --libs libgnomeui-2.0 freetype2 cairo` + +COMMON=cmaps.o UnicodeReader.o GnomeGUISupport.o FontMap.o GnomeFontMap.o ScriptCompositeFontInstance.o GnomeFontInstance.o FontTableCache.o paragraph.o + +OBJECTS=gnomelayout.o + +COBJECTS=gnomeglue.o pflow.o rsurface.o ucreader.o cgnomelayout.o + +DEPS = $(OBJECTS:.o=.d) + +## List of phony targets +.PHONY : all all-local install install-local clean clean-local \ +distclean distclean-local dist dist-local check check-local + +## Clear suffix list +.SUFFIXES : + +## List of standard targets +all: all-local +install: install-local +clean: clean-local +distclean : distclean-local +dist: dist-local +check: all check-local +c-all: c-all-local +c-check: c-all c-check-local + +all-local: $(TARGET) + +c-all-local: $(CTARGET) + +install-local: + +dist-local: + +clean-local: + test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) + $(RMV) $(COMMON) $(OBJECTS) $(COBJECTS) $(TARGET) + +distclean-local: clean-local + $(RMV) Makefile + +check-local: all-local + $(INVOKE) ./$(TARGET) + +c-check-local: c-all-local + $(INVOKE) ./$(CTARGET) + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +# The following two rules make it possible to +# compile scrptrun.cpp from the extra/scrptrun directory. +# they were copied from the default rules in mh-linux which +# is probably OK because this sample will only run on Linux... +scrptrun.d: $(top_srcdir)/extra/scrptrun/scrptrun.cpp + $(SHELL) -ec '$(GEN_DEPS.cc) $< \ + | sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \ + [ -s $@ ] || rm -f $@' + +scrptrun.o: $(top_srcdir)/extra/scrptrun/scrptrun.cpp + $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $< + +$(TARGET) : $(COMMON) $(OBJECTS) + $(LINK.cc) -o $@ $^ $(LIBS) + +$(CTARGET) : $(COMMON) $(COBJECTS) + $(LINK.cc) -o $@ $^ $(LIBS) + +invoke: + ICU_DATA=$${ICU_DATA:-$(top_builddir)/data/} TZ=PST8PDT $(INVOKE) $(INVOCATION) + +ifeq (,$(MAKECMDGOALS)) +-include $(DEPS) +else +ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) +-include $(DEPS) +endif +endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/RenderingSurface.h b/Build/source/libs/icu/icu-50.1/samples/layout/RenderingSurface.h new file mode 100644 index 00000000000..ab0ad561956 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/RenderingSurface.h @@ -0,0 +1,30 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: RenderingFontInstance.h + * + * created on: 02/20/2003 + * created by: Eric R. Mader + */ + +#ifndef __RENDERINGSURFACE_H +#define __RENDERINGSURFACE_H + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +class RenderingSurface +{ +public: + RenderingSurface() {}; + virtual ~RenderingSurface() {}; + + virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height) = 0; +}; + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/Sample.txt b/Build/source/libs/icu/icu-50.1/samples/layout/Sample.txt new file mode 100644 index 00000000000..367821b7933 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/Sample.txt @@ -0,0 +1 @@ +The LayoutEngine does all the work necessary to display Unicode text written in languages with complex writing systems such as Hindi (हिन्दी) Thai (ไทย) and Arabic (العربية). Here's a sample of some text written in Sanskrit: श्रीमद् भगवद्गीता अध्याय अर्जुन विषाद योग धृतराष्ट्र उवाच। धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः मामकाः पाण्डवाश्चैव किमकुर्वत संजय Here's a sample of some text written in Arabic: أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع "يونِكود"، كان هناك مئات الأنظمة للتشفير وتخصيص هذه الأرقام للمحارف، ولم يوجد نظام تشفير واحد يحتوي على جميع المحارف الضرورية and here's a sample of some text written in Thai: บทที่๑พายุไซโคลนโดโรธีอาศัยอยู่ท่ามกลางทุ่งใหญ่ในแคนซัสกับลุงเฮนรีชาวไร่และป้าเอ็มภรรยาชาวไร่บ้านของพวกเขาหลังเล็กเพราะไม้สร้างบ้านต้องขนมาด้วยเกวียนเป็นระยะทางหลายไมล์ diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/ScriptCompositeFontInstance.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/ScriptCompositeFontInstance.cpp new file mode 100644 index 00000000000..2fbbaca0d4b --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/ScriptCompositeFontInstance.cpp @@ -0,0 +1,103 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: ScriptCompositeFontInstance.cpp + * + * created on: 02/05/2003 + * created by: Eric R. Mader + */ + +#include "layout/LETypes.h" + +#include "unicode/uscript.h" + +#include "FontMap.h" + +#include "ScriptCompositeFontInstance.h" + +const char ScriptCompositeFontInstance::fgClassID=0; + +ScriptCompositeFontInstance::ScriptCompositeFontInstance(FontMap *fontMap) + : fFontMap(fontMap) +{ + // nothing else to do +} + +ScriptCompositeFontInstance::~ScriptCompositeFontInstance() +{ + delete fFontMap; + fFontMap = NULL; +} + +void ScriptCompositeFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const +{ + LEErrorCode status = LE_NO_ERROR; + le_int32 script = LE_GET_SUB_FONT(glyph); + const LEFontInstance *font = fFontMap->getScriptFont(script, status); + + advance.fX = 0; + advance.fY = 0; + + if (LE_SUCCESS(status)) { + font->getGlyphAdvance(LE_GET_GLYPH(glyph), advance); + } +} + +le_bool ScriptCompositeFontInstance::getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const +{ + LEErrorCode status = LE_NO_ERROR; + le_int32 script = LE_GET_SUB_FONT(glyph); + const LEFontInstance *font = fFontMap->getScriptFont(script, status); + + if (LE_SUCCESS(status)) { + return font->getGlyphPoint(LE_GET_GLYPH(glyph), pointNumber, point); + } + + return FALSE; +} + +const LEFontInstance *ScriptCompositeFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const +{ + if (LE_FAILURE(success)) { + return NULL; + } + + if (chars == NULL || *offset < 0 || limit < 0 || *offset >= limit || script < 0 || script >= scriptCodeCount) { + success = LE_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } + + const LEFontInstance *result = fFontMap->getScriptFont(script, success); + + if (LE_FAILURE(success)) { + return NULL; + } + + *offset = limit; + return result; +} + +// This is the really stupid version that doesn't look in any other font for the character... +// It would be better to also look in the "DEFAULT:" font. Another thing to do would be to +// look in all the fonts in some order, script code order being the most obvious... +LEGlyphID ScriptCompositeFontInstance::mapCharToGlyph(LEUnicode32 ch) const +{ + UErrorCode error = U_ZERO_ERROR; + LEErrorCode status = LE_NO_ERROR; + le_int32 script = uscript_getScript(ch, &error); + const LEFontInstance *scriptFont = fFontMap->getScriptFont(script, status); + LEGlyphID subFont = LE_SET_SUB_FONT(0, script); + + if (LE_FAILURE(status)) { + return subFont; + } + + LEGlyphID glyph = scriptFont->mapCharToGlyph(ch); + + return LE_SET_GLYPH(subFont, glyph); +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/ScriptCompositeFontInstance.h b/Build/source/libs/icu/icu-50.1/samples/layout/ScriptCompositeFontInstance.h new file mode 100644 index 00000000000..2a85480d76d --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/ScriptCompositeFontInstance.h @@ -0,0 +1,183 @@ +/* + * %W% %E% + * + * (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved + * + */ + +#ifndef __SCRIPTCOMPOSITEFONTINSTANCE_H +#define __SCRIPTCOMPOSITEFONTINSTANCE_H + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +#include "FontMap.h" + +// U_NAMESPACE_BEGIN + +class ScriptCompositeFontInstance : public LEFontInstance +{ +public: + + ScriptCompositeFontInstance(FontMap *fontMap); + + virtual ~ScriptCompositeFontInstance(); + + /** + * Get a physical font which can render the given text. For composite fonts, + * if there is no single physical font which can render all of the text, + * return a physical font which can render an initial substring of the text, + * and set the <code>offset</code> parameter to the end of that substring. + * + * Internally, the LayoutEngine works with runs of text all in the same + * font and script, so it is best to call this method with text which is + * in a single script, passing the script code in as a hint. If you don't + * know the script of the text, you can use zero, which is the script code + * for characters used in more than one script. + * + * The default implementation of this method is intended for instances of + * <code>LEFontInstance</code> which represent a physical font. It returns + * <code>this</code> and indicates that the entire string can be rendered. + * + * This method will return a valid <code>LEFontInstance</code> unless you + * have passed illegal parameters, or an internal error has been encountered. + * For composite fonts, it may return the warning <code>LE_NO_SUBFONT_WARNING</code> + * to indicate that the returned font may not be able to render all of + * the text. Whenever a valid font is returned, the <code>offset</code> parameter + * will be advanced by at least one. + * + * Subclasses which implement composite fonts must override this method. + * Where it makes sense, they should use the script code as a hint to render + * characters from the COMMON script in the font which is used for the given + * script. For example, if the input text is a series of Arabic words separated + * by spaces, and the script code passed in is <code>arabScriptCode</code> you + * should return the font used for Arabic characters for all of the input text, + * including the spaces. If, on the other hand, the input text contains characters + * which cannot be rendered by the font used for Arabic characters, but which can + * be rendered by another font, you should return that font for those characters. + * + * @param chars - the array of Unicode characters. + * @param offset - a pointer to the starting offset in the text. On exit this + * will be set the the limit offset of the text which can be + * rendered using the returned font. + * @param limit - the limit offset for the input text. + * @param script - the script hint. + * @param success - set to an error code if the arguments are illegal, or no font + * can be returned for some reason. May also be set to + * <code>LE_NO_SUBFONT_WARNING</code> if the subfont which + * was returned cannot render all of the text. + * + * @return an <code>LEFontInstance</code> for the sub font which can render the characters, or + * <code>NULL</code> if there is an error. + * + * @see LEScripts.h + */ + virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const; + + /** + * This method maps a single character to a glyph index, using the + * font's charcter to glyph map. + * + * @param ch - the character + * + * @return the glyph index + */ + virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; + + virtual const void *getFontTable(LETag tableTag) const; + + virtual le_int32 getUnitsPerEM() const; + + virtual le_int32 getAscent() const; + + virtual le_int32 getDescent() const; + + virtual le_int32 getLeading() const; + + virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; + + virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; + + float getXPixelsPerEm() const; + + float getYPixelsPerEm() const; + + float getScaleFactorX() const; + + float getScaleFactorY() const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +protected: + FontMap *fFontMap; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; +}; + +inline const void *ScriptCompositeFontInstance::getFontTable(LETag /*tableTag*/) const +{ + return NULL; +} + +// Can't get units per EM without knowing which sub-font, so +// return a value that will make units == points +inline le_int32 ScriptCompositeFontInstance::getUnitsPerEM() const +{ + return 1; +} + +inline le_int32 ScriptCompositeFontInstance::getAscent() const +{ + return fFontMap->getAscent(); +} + +inline le_int32 ScriptCompositeFontInstance::getDescent() const +{ + return fFontMap->getDescent(); +} + +inline le_int32 ScriptCompositeFontInstance::getLeading() const +{ + return fFontMap->getLeading(); +} + +inline float ScriptCompositeFontInstance::getXPixelsPerEm() const +{ + return fFontMap->getPointSize(); +} + +inline float ScriptCompositeFontInstance::getYPixelsPerEm() const +{ + return fFontMap->getPointSize(); +} + +// Can't get a scale factor without knowing the sub-font, so +// return 1.0. +inline float ScriptCompositeFontInstance::getScaleFactorX() const +{ + return 1.0; +} + +// Can't get a scale factor without knowing the sub-font, so +// return 1.0 +inline float ScriptCompositeFontInstance::getScaleFactorY() const +{ + return 1.0; +} + +// U_NAMESPACE_END +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/Surface.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/Surface.cpp new file mode 100644 index 00000000000..1f515241a95 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/Surface.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2003, International Business Machines + * Corporation and others. All Rights Reserved. + */ +void GDISurface::setFont(RenderingFontInstance *font) +{ + GDIFontInstance *gFont = (GDIFontInstance *) font; + + if (fCurrentFont != font) { + fCurrentFont = font; + SelectObject(fHdc, gFont->fFont); + } +} + +void GDISurface::drawGlyphs(RenderingFontInstance *font, const LEGlyphID *glyphs, le_int32 count, const le_int32 *dx, + le_int32 x, le_int32 y, le_int32 width, le_int32 height) +{ + RECT clip; + + clip.top = 0; + clip.left = 0; + clip.bottom = height; + clip.right = width; + + setFont(font); + + ExtTextOut(fHdc, x, y - fAscent, ETO_CLIPPED | ETO_GLYPH_INDEX, &clip, + glyphs, count, (INT *) dx); +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/Surface.h b/Build/source/libs/icu/icu-50.1/samples/layout/Surface.h new file mode 100644 index 00000000000..423ddaaf12c --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/Surface.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2003, International Business Machines + * Corporation and others. All Rights Reserved. + */ +class Surface +{ +public: + Surface(/*what?*/); + + void setFont(RenderingFontInstance *font); + + void drawGlyphs(RenderingFontInstance *font, const LEGlyphID *glyphs, le_int32 count, const le_int32 *dx, + le_int32 x, le_int32 y, le_int32 width, le_int32 height); +}; diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/UnicodeReader.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/UnicodeReader.cpp new file mode 100644 index 00000000000..ab5a7ef70b7 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/UnicodeReader.cpp @@ -0,0 +1,119 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2005, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#include <errno.h> +#include <stdio.h> +#include <string.h> + +#include "unicode/utypes.h" +#include "unicode/unistr.h" + +#include "layout/LETypes.h" + +#include "GUISupport.h" +#include "UnicodeReader.h" + +#define BYTE(b) (((int) b) & 0xFF) + +/* + * Read the text from a file. The text must start with a Unicode Byte + * Order Mark (BOM) so that we know what order to read the bytes in. + */ +const UChar *UnicodeReader::readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount) +{ + FILE *f; + int32_t fileSize; + + UChar *charBuffer; + char *byteBuffer; + char startBytes[4] = {'\xA5', '\xA5', '\xA5', '\xA5'}; + char errorMessage[128]; + const char *cp = ""; + int32_t signatureLength = 0; + + f = fopen(fileName, "rb"); + + if( f == NULL ) { + sprintf(errorMessage,"Couldn't open %s: %s \n", fileName, strerror(errno)); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + return 0; + } + + fseek(f, 0, SEEK_END); + fileSize = ftell(f); + + fseek(f, 0, SEEK_SET); + fread(startBytes, sizeof(char), 4, f); + + if (startBytes[0] == '\xFE' && startBytes[1] == '\xFF') { + cp = "UTF-16BE"; + signatureLength = 2; + } else if (startBytes[0] == '\xFF' && startBytes[1] == '\xFE') { + if (startBytes[2] == '\x00' && startBytes[3] == '\x00') { + cp = "UTF-32LE"; + signatureLength = 4; + } else { + cp = "UTF-16LE"; + signatureLength = 2; + } + } else if (startBytes[0] == '\xEF' && startBytes[1] == '\xBB' && startBytes[2] == '\xBF') { + cp = "UTF-8"; + signatureLength = 3; + } else if (startBytes[0] == '\x0E' && startBytes[1] == '\xFE' && startBytes[2] == '\xFF') { + cp = "SCSU"; + signatureLength = 3; + } else if (startBytes[0] == '\x00' && startBytes[1] == '\x00' && + startBytes[2] == '\xFE' && startBytes[3] == '\xFF') { + cp = "UTF-32BE"; + signatureLength = 4; + } else { + sprintf(errorMessage, "Couldn't detect the encoding of %s: (%2.2X, %2.2X, %2.2X, %2.2X)\n", fileName, + BYTE(startBytes[0]), BYTE(startBytes[1]), BYTE(startBytes[2]), BYTE(startBytes[3])); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + fclose(f); + return 0; + } + + fileSize -= signatureLength; + fseek(f, signatureLength, SEEK_SET); + byteBuffer = new char[fileSize]; + + if(byteBuffer == 0) { + sprintf(errorMessage,"Couldn't get memory for reading %s: %s \n", fileName, strerror(errno)); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + fclose(f); + return 0; + } + + fread(byteBuffer, sizeof(char), fileSize, f); + if( ferror(f) ) { + sprintf(errorMessage,"Couldn't read %s: %s \n", fileName, strerror(errno)); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + fclose(f); + delete[] byteBuffer; + return 0; + } + fclose(f); + + UnicodeString myText(byteBuffer, fileSize, cp); + + delete[] byteBuffer; + + charCount = myText.length(); + charBuffer = LE_NEW_ARRAY(UChar, charCount + 1); + if(charBuffer == 0) { + sprintf(errorMessage,"Couldn't get memory for reading %s: %s \n", fileName, strerror(errno)); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + return 0; + } + + myText.extract(0, myText.length(), charBuffer); + charBuffer[charCount] = 0; // NULL terminate for easier reading in the debugger + + return charBuffer; +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/UnicodeReader.h b/Build/source/libs/icu/icu-50.1/samples/layout/UnicodeReader.h new file mode 100644 index 00000000000..47959bb3a49 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/UnicodeReader.h @@ -0,0 +1,32 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2001, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#ifndef __UNICODEREADER_H +#define __UNICODEREADER_H + +#include "unicode/utypes.h" + +#include "GUISupport.h" + +class UnicodeReader +{ +public: + UnicodeReader() + { + // nothing... + } + + ~UnicodeReader() + { + // nothing, too + } + + static const UChar *readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount); +}; + +#endif + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/arraymem.h b/Build/source/libs/icu/icu-50.1/samples/layout/arraymem.h new file mode 100644 index 00000000000..7c54d96bdd0 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/arraymem.h @@ -0,0 +1,22 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __ARRAYMEM_H +#define __ARRAYMEM_H + +#include <stdlib.h> + +#define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) + +#define ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0]) + +#define NEW_ARRAY(type,count) (type *) malloc((count) * sizeof(type)) + +#define DELETE_ARRAY(array) free((void *) (array)) + +#define GROW_ARRAY(array,newSize) realloc((void *) (array), (newSize) * sizeof (array)[0]) + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/cgnomelayout.c b/Build/source/libs/icu/icu-50.1/samples/layout/cgnomelayout.c new file mode 100644 index 00000000000..f95b7a5c6bc --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/cgnomelayout.c @@ -0,0 +1,342 @@ + +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + */ + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "pflow.h" + +#include "gnomeglue.h" + +#include "arraymem.h" + +struct Context +{ + long width; + long height; + pf_flow *paragraph; +}; + +typedef struct Context Context; + +static FT_Library engine; +static gs_guiSupport *guiSupport; +static fm_fontMap *fontMap; +static le_font *font; + +static GSList *appList = NULL; + +GtkWidget *newSample(const gchar *fileName); +void closeSample(GtkWidget *sample); + +static void showabout(GtkWidget *widget, gpointer data) +{ + GtkWidget *aboutBox; + const gchar *documentedBy[] = {NULL}; + const gchar *writtenBy[] = { + "Eric Mader", + NULL + }; + + aboutBox = gnome_about_new("Gnome Layout Sample", + "0.1", + "Copyright (C) 1998-2006 By International Business Machines Corporation and others. All Rights Reserved.", + "A simple demo of the ICU LayoutEngine.", + writtenBy, + documentedBy, + "", + NULL); + + gtk_widget_show(aboutBox); +} + +#if 0 +static void notimpl(GtkObject *object, gpointer data) +{ + gnome_ok_dialog("Not implemented..."); +} +#endif + +static gchar *prettyTitle(const gchar *path) +{ + const gchar *name = g_basename(path); + gchar *title = g_strconcat("Gnome Layout Sample - ", name, NULL); + + return title; +} + +static void openOK(GtkObject *object, gpointer data) +{ + GtkFileSelection *fileselection = GTK_FILE_SELECTION(data); + GtkWidget *app = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(fileselection), "app")); + Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); + gchar *fileName = g_strdup(gtk_file_selection_get_filename(fileselection)); + pf_flow *newPara; + + gtk_widget_destroy(GTK_WIDGET(fileselection)); + + newPara = pf_factory(fileName, font, guiSupport); + + if (newPara != NULL) { + gchar *title = prettyTitle(fileName); + GtkWidget *area = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(app), "area")); + + if (context->paragraph != NULL) { + pf_close(context->paragraph); + } + + context->paragraph = newPara; + gtk_window_set_title(GTK_WINDOW(app), title); + + gtk_widget_hide(area); + pf_breakLines(context->paragraph, context->width, context->height); + gtk_widget_show_all(area); + + g_free(title); + } + + g_free(fileName); +} + +static void openfile(GtkObject *object, gpointer data) +{ + GtkWidget *app = GTK_WIDGET(data); + GtkWidget *fileselection; + GtkWidget *okButton; + GtkWidget *cancelButton; + + fileselection = + gtk_file_selection_new("Open File"); + + gtk_object_set_data(GTK_OBJECT(fileselection), "app", app); + + okButton = + GTK_FILE_SELECTION(fileselection)->ok_button; + + cancelButton = + GTK_FILE_SELECTION(fileselection)->cancel_button; + + gtk_signal_connect(GTK_OBJECT(fileselection), "destroy", + GTK_SIGNAL_FUNC(gtk_main_quit), NULL); + + gtk_signal_connect(GTK_OBJECT(okButton), "clicked", + GTK_SIGNAL_FUNC(openOK), fileselection); + + gtk_signal_connect_object(GTK_OBJECT(cancelButton), "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(fileselection)); + + gtk_window_set_modal(GTK_WINDOW(fileselection), TRUE); + gtk_widget_show(fileselection); + gtk_main(); +} + +static void newapp(GtkObject *object, gpointer data) +{ + GtkWidget *app = newSample("Sample.txt"); + + gtk_widget_show_all(app); +} + +static void closeapp(GtkWidget *widget, gpointer data) +{ + GtkWidget *app = GTK_WIDGET(data); + + closeSample(app); +} + +static void shutdown(GtkObject *object, gpointer data) +{ + gtk_main_quit(); +} + +GnomeUIInfo fileMenu[] = +{ + GNOMEUIINFO_MENU_NEW_ITEM((gchar *) "_New Sample", + (gchar *) "Create a new Gnome Layout Sample", + newapp, NULL), + + GNOMEUIINFO_MENU_OPEN_ITEM(openfile, NULL), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_MENU_CLOSE_ITEM(closeapp, NULL), + GNOMEUIINFO_MENU_EXIT_ITEM(shutdown, NULL), + GNOMEUIINFO_END +}; + +GnomeUIInfo helpMenu[] = +{ + /* GNOMEUIINFO_HELP("gnomelayout"), */ + GNOMEUIINFO_MENU_ABOUT_ITEM(showabout, NULL), + GNOMEUIINFO_END +}; + +GnomeUIInfo mainMenu[] = +{ + GNOMEUIINFO_SUBTREE(N_((gchar *) "File"), fileMenu), + GNOMEUIINFO_SUBTREE(N_((gchar *) "Help"), helpMenu), + GNOMEUIINFO_END +}; + +static gint eventDelete(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + closeSample(widget); + + /* indicate that closeapp already destroyed the window */ + return TRUE; +} + +static gint eventConfigure(GtkWidget *widget, GdkEventConfigure *event, Context *context) +{ + if (context->paragraph != NULL) { + context->width = event->width; + context->height = event->height; + + if (context->width > 0 && context->height > 0) { + pf_breakLines(context->paragraph, context->width, context->height); + } + } + + return TRUE; +} + +static gint eventExpose(GtkWidget *widget, GdkEvent *event, Context *context) +{ + if (context->paragraph != NULL) { + gint maxLines = pf_getLineCount(context->paragraph) - 1; + gint firstLine = 0, lastLine = context->height / pf_getLineHeight(context->paragraph); + rs_surface *surface = rs_gnomeRenderingSurfaceOpen(widget); + + pf_draw(context->paragraph, surface, firstLine, (maxLines < lastLine)? maxLines : lastLine); + + rs_gnomeRenderingSurfaceClose(surface); + } + + return TRUE; +} + +GtkWidget *newSample(const gchar *fileName) +{ + Context *context = NEW_ARRAY(Context, 1); + gchar *title; + GtkWidget *app; + GtkWidget *area; + GtkStyle *style; + int i; + + context->width = 600; + context->height = 400; + context->paragraph = pf_factory(fileName, font, guiSupport); + + title = prettyTitle(fileName); + app = gnome_app_new("gnomeLayout", title); + + gtk_object_set_data(GTK_OBJECT(app), "context", context); + + gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400); + + gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app); + + gtk_signal_connect(GTK_OBJECT(app), "delete_event", + GTK_SIGNAL_FUNC(eventDelete), NULL); + + area = gtk_drawing_area_new(); + gtk_object_set_data(GTK_OBJECT(app), "area", area); + + style = gtk_style_copy(gtk_widget_get_style(area)); + + for (i = 0; i < 5; i += 1) { + style->fg[i] = style->white; + } + + gtk_widget_set_style(area, style); + + gnome_app_set_contents(GNOME_APP(app), area); + + gtk_signal_connect(GTK_OBJECT(area), + "expose_event", + GTK_SIGNAL_FUNC(eventExpose), + context); + + gtk_signal_connect(GTK_OBJECT(area), + "configure_event", + GTK_SIGNAL_FUNC(eventConfigure), + context); + + appList = g_slist_prepend(appList, app); + + g_free(title); + + return app; +} + +void closeSample(GtkWidget *app) +{ + Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); + + if (context->paragraph != NULL) { + pf_close(context->paragraph); + } + + DELETE_ARRAY(context); + + appList = g_slist_remove(appList, app); + + gtk_widget_destroy(app); + + if (appList == NULL) { + gtk_main_quit(); + } +} + +int main (int argc, char *argv[]) +{ + LEErrorCode fontStatus = LE_NO_ERROR; + poptContext ptctx; + GtkWidget *app; + const char *defaultArgs[] = {"Sample.txt", NULL}; + const char **args; + int i; + + FT_Init_FreeType(&engine); + + gnome_init_with_popt_table("gnomelayout", "0.1", argc, argv, NULL, 0, &ptctx); + + guiSupport = gs_gnomeGuiSupportOpen(); + fontMap = fm_gnomeFontMapOpen(engine, "FontMap.Gnome", 24, guiSupport, &fontStatus); + font = le_scriptCompositeFontOpen(fontMap); + + if (LE_FAILURE(fontStatus)) { + FT_Done_FreeType(engine); + return 1; + } + + args = poptGetArgs(ptctx); + + if (args == NULL) { + args = defaultArgs; + } + + for (i = 0; args[i] != NULL; i += 1) { + app = newSample(args[i]); + + gtk_widget_show_all(app); + } + + poptFreeContext(ptctx); + + gtk_main(); + + le_fontClose(font); + gs_gnomeGuiSupportClose(guiSupport); + + FT_Done_FreeType(engine); + + exit(0); +} diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/clayout.c b/Build/source/libs/icu/icu-50.1/samples/layout/clayout.c new file mode 100644 index 00000000000..701ab8dc09c --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/clayout.c @@ -0,0 +1,363 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: Layout.cpp + * + * created on: 08/03/2000 + * created by: Eric R. Mader + */ + +#include <windows.h> +#include <stdio.h> + +#include "playout.h" +#include "pflow.h" + +#include "gdiglue.h" +#include "ucreader.h" + +#include "arraymem.h" + +#include "resource.h" + +struct Context +{ + le_int32 width; + le_int32 height; + pf_flow *paragraph; +}; + +typedef struct Context Context; + +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + +#define APP_NAME "LayoutSample" + +TCHAR szAppName[] = TEXT(APP_NAME); + +void PrettyTitle(HWND hwnd, char *fileName) +{ + char title[MAX_PATH + 64]; + + sprintf(title, "%s - %s", APP_NAME, fileName); + + SetWindowTextA(hwnd, title); +} + +void InitParagraph(HWND hwnd, Context *context) +{ + SCROLLINFO si; + + if (context->paragraph != NULL) { + // FIXME: does it matter what we put in the ScrollInfo + // if the window's been minimized? + if (context->width > 0 && context->height > 0) { + pf_breakLines(context->paragraph, context->width, context->height); + } + + si.cbSize = sizeof si; + si.fMask = SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL; + si.nMin = 0; + si.nMax = pf_getLineCount(context->paragraph) - 1; + si.nPage = context->height / pf_getLineHeight(context->paragraph); + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + } +} + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) +{ + HWND hwnd; + HACCEL hAccel; + MSG msg; + WNDCLASS wndclass; + LEErrorCode status = LE_NO_ERROR; + + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = WndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = sizeof(LONG); + wndclass.hInstance = hInstance; + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); + wndclass.lpszMenuName = szAppName; + wndclass.lpszClassName = szAppName; + + if (!RegisterClass(&wndclass)) { + MessageBox(NULL, TEXT("This demo only runs on Windows 2000!"), szAppName, MB_ICONERROR); + + return 0; + } + + hAccel = LoadAccelerators(hInstance, szAppName); + + hwnd = CreateWindow(szAppName, NULL, + WS_OVERLAPPEDWINDOW | WS_VSCROLL, + CW_USEDEFAULT, CW_USEDEFAULT, + 600, 400, + NULL, NULL, hInstance, NULL); + + ShowWindow(hwnd, iCmdShow); + UpdateWindow(hwnd); + + while (GetMessage(&msg, NULL, 0, 0)) { + if (!TranslateAccelerator(hwnd, hAccel, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + UnregisterClass(szAppName, hInstance); + return msg.wParam; +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + Context *context; + static le_int32 windowCount = 0; + static fm_fontMap *fontMap = NULL; + static rs_surface *surface = NULL; + static gs_guiSupport *guiSupport = NULL; + static le_font *font = NULL; + + switch (message) { + case WM_CREATE: + { + LEErrorCode fontStatus = LE_NO_ERROR; + + hdc = GetDC(hwnd); + guiSupport = gs_gdiGuiSupportOpen(); + surface = rs_gdiRenderingSurfaceOpen(hdc); + + fontMap = fm_gdiFontMapOpen(surface, "FontMap.GDI", 24, guiSupport, &fontStatus); + font = le_scriptCompositeFontOpen(fontMap); + + if (LE_FAILURE(fontStatus)) { + ReleaseDC(hwnd, hdc); + return -1; + } + + context = NEW_ARRAY(Context, 1); + + context->width = 600; + context->height = 400; + + context->paragraph = pf_factory("Sample.txt", font, guiSupport); + SetWindowLongPtr(hwnd, 0, (LONG_PTR) context); + + windowCount += 1; + ReleaseDC(hwnd, hdc); + + PrettyTitle(hwnd, "Sample.txt"); + return 0; + } + + case WM_SIZE: + { + context = (Context *) GetWindowLongPtr(hwnd, 0); + context->width = LOWORD(lParam); + context->height = HIWORD(lParam); + + InitParagraph(hwnd, context); + return 0; + } + + case WM_VSCROLL: + { + SCROLLINFO si; + le_int32 vertPos; + + si.cbSize = sizeof si; + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, &si); + + vertPos = si.nPos; + + switch (LOWORD(wParam)) + { + case SB_TOP: + si.nPos = si.nMin; + break; + + case SB_BOTTOM: + si.nPos = si.nMax; + break; + + case SB_LINEUP: + si.nPos -= 1; + break; + + case SB_LINEDOWN: + si.nPos += 1; + break; + + case SB_PAGEUP: + si.nPos -= si.nPage; + break; + + case SB_PAGEDOWN: + si.nPos += si.nPage; + break; + + case SB_THUMBTRACK: + si.nPos = si.nTrackPos; + break; + + default: + break; + } + + si.fMask = SIF_POS; + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + GetScrollInfo(hwnd, SB_VERT, &si); + + context = (Context *) GetWindowLongPtr(hwnd, 0); + + if (context->paragraph != NULL && si.nPos != vertPos) { + ScrollWindow(hwnd, 0, pf_getLineHeight(context->paragraph) * (vertPos - si.nPos), NULL, NULL); + UpdateWindow(hwnd); + } + + return 0; + } + + case WM_PAINT: + { + PAINTSTRUCT ps; + SCROLLINFO si; + le_int32 firstLine, lastLine; + + hdc = BeginPaint(hwnd, &ps); + SetBkMode(hdc, TRANSPARENT); + + si.cbSize = sizeof si; + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, &si); + + firstLine = si.nPos; + + context = (Context *) GetWindowLongPtr(hwnd, 0); + + if (context->paragraph != NULL) { + rs_gdiRenderingSurfaceSetHDC(surface, hdc); + + // NOTE: si.nPos + si.nPage may include a partial line at the bottom + // of the window. We need this because scrolling assumes that the + // partial line has been painted. + lastLine = min (si.nPos + (le_int32) si.nPage, pf_getLineCount(context->paragraph) - 1); + + pf_draw(context->paragraph, surface, firstLine, lastLine); + } + + EndPaint(hwnd, &ps); + return 0; + } + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDM_FILE_OPEN: + { + OPENFILENAMEA ofn; + char szFileName[MAX_PATH], szTitleName[MAX_PATH]; + static char szFilter[] = "Text Files (.txt)\0*.txt\0" + "All Files (*.*)\0*.*\0\0"; + + ofn.lStructSize = sizeof (OPENFILENAMEA); + ofn.hwndOwner = hwnd; + ofn.hInstance = NULL; + ofn.lpstrFilter = szFilter; + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 0; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = szTitleName; + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle = NULL; + ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + ofn.nFileOffset = 0; + ofn.nFileExtension = 0; + ofn.lpstrDefExt = "txt"; + ofn.lCustData = 0L; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; + + szFileName[0] = '\0'; + + if (GetOpenFileNameA(&ofn)) { + pf_flow *newParagraph; + + hdc = GetDC(hwnd); + rs_gdiRenderingSurfaceSetHDC(surface, hdc); + + newParagraph = pf_factory(szFileName, font, guiSupport); + + if (newParagraph != NULL) { + context = (Context *) GetWindowLongPtr(hwnd, 0); + + if (context->paragraph != NULL) { + pf_close(context->paragraph); + } + + context->paragraph = newParagraph; + InitParagraph(hwnd, context); + PrettyTitle(hwnd, szTitleName); + InvalidateRect(hwnd, NULL, TRUE); + + } + } + + //ReleaseDC(hwnd, hdc); + + return 0; + } + + case IDM_FILE_EXIT: + case IDM_FILE_CLOSE: + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; + + case IDM_HELP_ABOUTLAYOUTSAMPLE: + MessageBox(hwnd, TEXT("Windows Layout Sample 0.1\n") + TEXT("Copyright (C) 1998-2005 By International Business Machines Corporation and others.\n") + TEXT("Author: Eric Mader"), + szAppName, MB_ICONINFORMATION | MB_OK); + return 0; + + } + break; + + + case WM_DESTROY: + { + context = (Context *) GetWindowLongPtr(hwnd, 0); + + if (context != NULL && context->paragraph != NULL) { + pf_close(context->paragraph); + } + + DELETE_ARRAY(context); + + if (--windowCount <= 0) { + le_fontClose(font); + rs_gdiRenderingSurfaceClose(surface); + gs_gdiGuiSupportClose(guiSupport); + + PostQuitMessage(0); + } + + return 0; + } + + default: + return DefWindowProc(hwnd, message, wParam, lParam); + } + + return 0; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/cmaps.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/cmaps.cpp new file mode 100644 index 00000000000..33b5cbb801f --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/cmaps.cpp @@ -0,0 +1,206 @@ +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + * file name: cmaps.cpp + * + * created on: ??/??/2001 + * created by: Eric R. Mader + */ + +#include "layout/LETypes.h" +#include "layout/LESwaps.h" + +#include "sfnt.h" +#include "cmaps.h" + +#define SWAPU16(code) ((LEUnicode16) SWAPW(code)) +#define SWAPU32(code) ((LEUnicode32) SWAPL(code)) + +// +// Finds the high bit by binary searching +// through the bits in value. +// +le_uint8 highBit(le_uint32 value) +{ + le_uint8 bit = 0; + + if (value >= 1 << 16) { + value >>= 16; + bit += 16; + } + + if (value >= 1 << 8) { + value >>= 8; + bit += 8; + } + + if (value >= 1 << 4) { + value >>= 4; + bit += 4; + } + + if (value >= 1 << 2) { + value >>= 2; + bit += 2; + } + + if (value >= 1 << 1) { + value >>= 1; + bit += 1; + } + + return bit; +} + +CMAPMapper *CMAPMapper::createUnicodeMapper(const CMAPTable *cmap) +{ + le_uint16 i; + le_uint16 nSubtables = SWAPW(cmap->numberSubtables); + const CMAPEncodingSubtable *subtable = NULL; + le_uint32 offset1 = 0, offset10 = 0; + + for (i = 0; i < nSubtables; i += 1) { + const CMAPEncodingSubtableHeader *esh = &cmap->encodingSubtableHeaders[i]; + + if (SWAPW(esh->platformID) == 3) { + switch (SWAPW(esh->platformSpecificID)) { + case 1: + offset1 = SWAPL(esh->encodingOffset); + break; + + case 10: + offset10 = SWAPL(esh->encodingOffset); + break; + } + } + } + + + if (offset10 != 0) + { + subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + offset10); + } else if (offset1 != 0) { + subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + offset1); + } else { + return NULL; + } + + switch (SWAPW(subtable->format)) { + case 4: + return new CMAPFormat4Mapper(cmap, (const CMAPFormat4Encoding *) subtable); + + case 12: + { + const CMAPFormat12Encoding *encoding = (const CMAPFormat12Encoding *) subtable; + + return new CMAPGroupMapper(cmap, encoding->groups, SWAPL(encoding->nGroups)); + } + + default: + break; + } + + return NULL; +} + +CMAPFormat4Mapper::CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header) + : CMAPMapper(cmap) +{ + le_uint16 segCount = SWAPW(header->segCountX2) / 2; + + fEntrySelector = SWAPW(header->entrySelector); + fRangeShift = SWAPW(header->rangeShift) / 2; + fEndCodes = &header->endCodes[0]; + fStartCodes = &header->endCodes[segCount + 1]; // + 1 for reservedPad... + fIdDelta = &fStartCodes[segCount]; + fIdRangeOffset = &fIdDelta[segCount]; +} + +LEGlyphID CMAPFormat4Mapper::unicodeToGlyph(LEUnicode32 unicode32) const +{ + if (unicode32 >= 0x10000) { + return 0; + } + + LEUnicode16 unicode = (LEUnicode16) unicode32; + le_uint16 index = 0; + le_uint16 probe = 1 << fEntrySelector; + TTGlyphID result = 0; + + if (SWAPU16(fStartCodes[fRangeShift]) <= unicode) { + index = fRangeShift; + } + + while (probe > (1 << 0)) { + probe >>= 1; + + if (SWAPU16(fStartCodes[index + probe]) <= unicode) { + index += probe; + } + } + + if (unicode >= SWAPU16(fStartCodes[index]) && unicode <= SWAPU16(fEndCodes[index])) { + if (fIdRangeOffset[index] == 0) { + result = (TTGlyphID) unicode; + } else { + le_uint16 offset = unicode - SWAPU16(fStartCodes[index]); + le_uint16 rangeOffset = SWAPW(fIdRangeOffset[index]); + le_uint16 *glyphIndexTable = (le_uint16 *) ((char *) &fIdRangeOffset[index] + rangeOffset); + + result = SWAPW(glyphIndexTable[offset]); + } + + result += SWAPW(fIdDelta[index]); + } else { + result = 0; + } + + return LE_SET_GLYPH(0, result); +} + +CMAPFormat4Mapper::~CMAPFormat4Mapper() +{ + // parent destructor does it all +} + +CMAPGroupMapper::CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups) + : CMAPMapper(cmap), fGroups(groups) +{ + le_uint8 bit = highBit(nGroups); + fPower = 1 << bit; + fRangeOffset = nGroups - fPower; +} + +LEGlyphID CMAPGroupMapper::unicodeToGlyph(LEUnicode32 unicode32) const +{ + le_int32 probe = fPower; + le_int32 range = 0; + + if (SWAPU32(fGroups[fRangeOffset].startCharCode) <= unicode32) { + range = fRangeOffset; + } + + while (probe > (1 << 0)) { + probe >>= 1; + + if (SWAPU32(fGroups[range + probe].startCharCode) <= unicode32) { + range += probe; + } + } + + if (SWAPU32(fGroups[range].startCharCode) <= unicode32 && SWAPU32(fGroups[range].endCharCode) >= unicode32) { + return (LEGlyphID) (SWAPU32(fGroups[range].startGlyphCode) + unicode32 - SWAPU32(fGroups[range].startCharCode)); + } + + return 0; +} + +CMAPGroupMapper::~CMAPGroupMapper() +{ + // parent destructor does it all +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/cmaps.h b/Build/source/libs/icu/icu-50.1/samples/layout/cmaps.h new file mode 100644 index 00000000000..868c357b763 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/cmaps.h @@ -0,0 +1,89 @@ +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + * file name: cmaps.h + * + * created on: ??/??/2001 + * created by: Eric R. Mader + */ + +#ifndef __CMAPS_H +#define __CMAPS_H + +#include "layout/LETypes.h" +#include "sfnt.h" + +class CMAPMapper +{ +public: + virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const = 0; + + virtual ~CMAPMapper(); + + static CMAPMapper *createUnicodeMapper(const CMAPTable *cmap); + +protected: + CMAPMapper(const CMAPTable *cmap); + + CMAPMapper() {}; + +private: + const CMAPTable *fcmap; +}; + +class CMAPFormat4Mapper : public CMAPMapper +{ +public: + CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header); + + virtual ~CMAPFormat4Mapper(); + + virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const; + +protected: + CMAPFormat4Mapper() {}; + +private: + le_uint16 fEntrySelector; + le_uint16 fRangeShift; + const le_uint16 *fEndCodes; + const le_uint16 *fStartCodes; + const le_uint16 *fIdDelta; + const le_uint16 *fIdRangeOffset; +}; + +class CMAPGroupMapper : public CMAPMapper +{ +public: + CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups); + + virtual ~CMAPGroupMapper(); + + virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const; + +protected: + CMAPGroupMapper() {}; + +private: + le_int32 fPower; + le_int32 fRangeOffset; + const CMAPGroup *fGroups; +}; + +inline CMAPMapper::CMAPMapper(const CMAPTable *cmap) + : fcmap(cmap) +{ + // nothing else to do +} + +inline CMAPMapper::~CMAPMapper() +{ + LE_DELETE_ARRAY(fcmap); +} + +#endif + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/gdiglue.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/gdiglue.cpp new file mode 100644 index 00000000000..e553c0617b1 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/gdiglue.cpp @@ -0,0 +1,80 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include <windows.h> + +#include "unicode/utypes.h" +#include "loengine.h" +#include "rsurface.h" +#include "gsupport.h" + +#include "gdiglue.h" + +#include "LETypes.h" +#include "LEFontInstance.h" +#include "GDIGUISupport.h" +#include "GDIFontMap.h" +#include "ScriptCompositeFontInstance.h" + + +U_CDECL_BEGIN + +gs_guiSupport *gs_gdiGuiSupportOpen() +{ + return (gs_guiSupport *) new GDIGUISupport(); +} + +void gs_gdiGuiSupportClose(gs_guiSupport *guiSupport) +{ + GDIGUISupport *gs = (GDIGUISupport *) guiSupport; + + delete gs; +} + +rs_surface *rs_gdiRenderingSurfaceOpen(HDC hdc) +{ + return (rs_surface *) new GDISurface(hdc); +} + +void rs_gdiRenderingSurfaceSetHDC(rs_surface *surface, HDC hdc) +{ + GDISurface *rs = (GDISurface *) surface; + + rs->setHDC(hdc); +} + +void rs_gdiRenderingSurfaceClose(rs_surface *surface) +{ + GDISurface *rs = (GDISurface *) surface; + + delete rs; +} + +fm_fontMap *fm_gdiFontMapOpen(rs_surface *surface, const char *fileName, le_int16 pointSize, gs_guiSupport *guiSupport, LEErrorCode *status) +{ + return (fm_fontMap *) new GDIFontMap((GDISurface *) surface, fileName, pointSize, (GDIGUISupport *) guiSupport, *status); +} + +void fm_fontMapClose(fm_fontMap *fontMap) +{ + GDIFontMap *fm = (GDIFontMap *) fontMap; + + delete fm; +} + +le_font *le_scriptCompositeFontOpen(fm_fontMap *fontMap) +{ + return (le_font *) new ScriptCompositeFontInstance((FontMap *) fontMap); +} + +void le_fontClose(le_font *font) +{ + LEFontInstance *fi = (LEFontInstance *) font; + + delete fi; +} + +U_CDECL_END diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/gdiglue.h b/Build/source/libs/icu/icu-50.1/samples/layout/gdiglue.h new file mode 100644 index 00000000000..bdd8422bb65 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/gdiglue.h @@ -0,0 +1,38 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __GDIGLUE_H +#define __GDIGLUE_H + +#include <windows.h> + +#include "unicode/utypes.h" + +#include "LETypes.h" +#include "loengine.h" +#include "gsupport.h" +#include "rsurface.h" + +typedef void fm_fontMap; + +U_CDECL_BEGIN + +gs_guiSupport *gs_gdiGuiSupportOpen(); +void gs_gdiGuiSupportClose(gs_guiSupport *guiSupport); + +rs_surface *rs_gdiRenderingSurfaceOpen(HDC hdc); +void rs_gdiRenderingSurfaceSetHDC(rs_surface *surface, HDC hdc); +void rs_gdiRenderingSurfaceClose(rs_surface *surface); + +fm_fontMap *fm_gdiFontMapOpen(rs_surface *surface, const char *fileName, le_int16 pointSize, gs_guiSupport *guiSupport, LEErrorCode *status); +void fm_fontMapClose(fm_fontMap *fontMap); + +le_font *le_scriptCompositeFontOpen(fm_fontMap *fontMap); +void le_fontClose(le_font *font); + +U_CDECL_END + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/gnomeglue.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/gnomeglue.cpp new file mode 100644 index 00000000000..a081e0bfcbf --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/gnomeglue.cpp @@ -0,0 +1,76 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "unicode/utypes.h" +#include "loengine.h" +#include "rsurface.h" +#include "gsupport.h" + +#include "gnomeglue.h" + +#include "LETypes.h" +#include "LEFontInstance.h" +#include "GnomeGUISupport.h" +#include "GnomeFontMap.h" +#include "GnomeFontInstance.h" +#include "ScriptCompositeFontInstance.h" + + +U_CDECL_BEGIN + +gs_guiSupport *gs_gnomeGuiSupportOpen() +{ + return (gs_guiSupport *) new GnomeGUISupport(); +} + +void gs_gnomeGuiSupportClose(gs_guiSupport *guiSupport) +{ + GnomeGUISupport *gs = (GnomeGUISupport *) guiSupport; + + delete gs; +} + +rs_surface *rs_gnomeRenderingSurfaceOpen(GtkWidget *theWidget) +{ + return (rs_surface *) new GnomeSurface(theWidget); +} + +void rs_gnomeRenderingSurfaceClose(rs_surface *surface) +{ + GnomeSurface *rs = (GnomeSurface *) surface; + + delete rs; +} + +fm_fontMap *fm_gnomeFontMapOpen(FT_Library engine, const char *fileName, le_int16 pointSize, gs_guiSupport *guiSupport, LEErrorCode *status) +{ + return (fm_fontMap *) new GnomeFontMap(engine, fileName, pointSize, (GnomeGUISupport *) guiSupport, *status); +} + +void fm_fontMapClose(fm_fontMap *fontMap) +{ + GnomeFontMap *fm = (GnomeFontMap *) fontMap; + + delete fm; +} + +le_font *le_scriptCompositeFontOpen(fm_fontMap *fontMap) +{ + return (le_font *) new ScriptCompositeFontInstance((FontMap *) fontMap); +} + +void le_fontClose(le_font *font) +{ + LEFontInstance *fi = (LEFontInstance *) font; + + delete fi; +} + +U_CDECL_END diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/gnomeglue.h b/Build/source/libs/icu/icu-50.1/samples/layout/gnomeglue.h new file mode 100644 index 00000000000..78561468eee --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/gnomeglue.h @@ -0,0 +1,39 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __GNOMEGLUE_H +#define __GNOMEGLUE_H + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "unicode/utypes.h" + +#include "LETypes.h" +#include "loengine.h" +#include "gsupport.h" +#include "rsurface.h" + +typedef void fm_fontMap; + +U_CDECL_BEGIN + +gs_guiSupport *gs_gnomeGuiSupportOpen(); +void gs_gnomeGuiSupportClose(gs_guiSupport *guiSupport); + +rs_surface *rs_gnomeRenderingSurfaceOpen(GtkWidget *theWidget); +void rs_gnomeRenderingSurfaceClose(rs_surface *surface); + +fm_fontMap *fm_gnomeFontMapOpen(FT_Library engine, const char *fileName, le_int16 pointSize, gs_guiSupport *guiSupport, LEErrorCode *status); +void fm_fontMapClose(fm_fontMap *fontMap); + +le_font *le_scriptCompositeFontOpen(fm_fontMap *fontMap); +void le_fontClose(le_font *font); + +U_CDECL_END + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/gnomelayout.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/gnomelayout.cpp new file mode 100644 index 00000000000..31e25871d45 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/gnomelayout.cpp @@ -0,0 +1,341 @@ + +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + * file name: gnomelayout.cpp + * + * created on: 09/04/2001 + * created by: Eric R. Mader + */ + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "unicode/ustring.h" +#include "unicode/uscript.h" + +#include "GnomeFontInstance.h" + +#include "paragraph.h" + +#include "GnomeGUISupport.h" +#include "GnomeFontMap.h" +#include "UnicodeReader.h" +#include "ScriptCompositeFontInstance.h" + +#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0]) + +struct Context +{ + long width; + long height; + Paragraph *paragraph; +}; + +static FT_Library engine; +static GnomeGUISupport *guiSupport; +static GnomeFontMap *fontMap; +static ScriptCompositeFontInstance *font; + +static GSList *appList = NULL; + +GtkWidget *newSample(const gchar *fileName); +void closeSample(GtkWidget *sample); + +void showabout(GtkWidget */*widget*/, gpointer /*data*/) +{ + GtkWidget *aboutBox; + const gchar *documentedBy[] = {NULL}; + const gchar *writtenBy[] = { + "Eric Mader", + NULL + }; + + aboutBox = gnome_about_new("Gnome Layout Sample", + "0.1", + "Copyright (C) 1998-2006 By International Business Machines Corporation and others. All Rights Reserved.", + "A simple demo of the ICU LayoutEngine.", + writtenBy, + documentedBy, + "", + NULL); + + gtk_widget_show(aboutBox); +} + +void notimpl(GtkObject */*object*/, gpointer /*data*/) +{ + gnome_ok_dialog("Not implemented..."); +} + +gchar *prettyTitle(const gchar *path) +{ + const gchar *name = g_basename(path); + gchar *title = g_strconcat("Gnome Layout Sample - ", name, NULL); + + return title; +} + +void openOK(GtkObject */*object*/, gpointer data) +{ + GtkFileSelection *fileselection = GTK_FILE_SELECTION(data); + GtkWidget *app = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(fileselection), "app")); + Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); + gchar *fileName = g_strdup(gtk_file_selection_get_filename(fileselection)); + Paragraph *newPara; + + gtk_widget_destroy(GTK_WIDGET(fileselection)); + + newPara = Paragraph::paragraphFactory(fileName, font, guiSupport); + + if (newPara != NULL) { + gchar *title = prettyTitle(fileName); + GtkWidget *area = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(app), "area")); + + if (context->paragraph != NULL) { + delete context->paragraph; + } + + context->paragraph = newPara; + gtk_window_set_title(GTK_WINDOW(app), title); + + gtk_widget_hide(area); + context->paragraph->breakLines(context->width, context->height); + gtk_widget_show_all(area); + + g_free(title); + } + + g_free(fileName); +} + +void openfile(GtkObject */*object*/, gpointer data) +{ + GtkWidget *app = GTK_WIDGET(data); + GtkWidget *fileselection; + GtkWidget *okButton; + GtkWidget *cancelButton; + + fileselection = + gtk_file_selection_new("Open File"); + + gtk_object_set_data(GTK_OBJECT(fileselection), "app", app); + + okButton = + GTK_FILE_SELECTION(fileselection)->ok_button; + + cancelButton = + GTK_FILE_SELECTION(fileselection)->cancel_button; + + gtk_signal_connect(GTK_OBJECT(fileselection), "destroy", + GTK_SIGNAL_FUNC(gtk_main_quit), NULL); + + gtk_signal_connect(GTK_OBJECT(okButton), "clicked", + GTK_SIGNAL_FUNC(openOK), fileselection); + + gtk_signal_connect_object(GTK_OBJECT(cancelButton), "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(fileselection)); + + gtk_window_set_modal(GTK_WINDOW(fileselection), TRUE); + gtk_widget_show(fileselection); + gtk_main(); +} + +void newapp(GtkObject */*object*/, gpointer /*data*/) +{ + GtkWidget *app = newSample("Sample.txt"); + + gtk_widget_show_all(app); +} + +void closeapp(GtkWidget */*widget*/, gpointer data) +{ + GtkWidget *app = GTK_WIDGET(data); + + closeSample(app); +} + +void shutdown(GtkObject */*object*/, gpointer /*data*/) +{ + gtk_main_quit(); +} + +GnomeUIInfo fileMenu[] = +{ + GNOMEUIINFO_MENU_NEW_ITEM((gchar *) "_New Sample", + (gchar *) "Create a new Gnome Layout Sample", + newapp, NULL), + + GNOMEUIINFO_MENU_OPEN_ITEM(openfile, NULL), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_MENU_CLOSE_ITEM(closeapp, NULL), + GNOMEUIINFO_MENU_EXIT_ITEM(shutdown, NULL), + GNOMEUIINFO_END +}; + +GnomeUIInfo helpMenu[] = +{ + // GNOMEUIINFO_HELP("gnomelayout"), + GNOMEUIINFO_MENU_ABOUT_ITEM(showabout, NULL), + GNOMEUIINFO_END +}; + +GnomeUIInfo mainMenu[] = +{ + GNOMEUIINFO_SUBTREE(N_((gchar *) "File"), fileMenu), + GNOMEUIINFO_SUBTREE(N_((gchar *) "Help"), helpMenu), + GNOMEUIINFO_END +}; + +gint eventDelete(GtkWidget *widget, GdkEvent */*event*/, gpointer /*data*/) +{ + closeSample(widget); + + // indicate that closeapp already destroyed the window + return TRUE; +} + +gint eventConfigure(GtkWidget */*widget*/, GdkEventConfigure *event, Context *context) +{ + if (context->paragraph != NULL) { + context->width = event->width; + context->height = event->height; + + if (context->width > 0 && context->height > 0) { + context->paragraph->breakLines(context->width, context->height); + } + } + + return TRUE; +} + +gint eventExpose(GtkWidget *widget, GdkEvent */*event*/, Context *context) +{ + if (context->paragraph != NULL) { + gint maxLines = context->paragraph->getLineCount() - 1; + gint firstLine = 0, lastLine = context->height / context->paragraph->getLineHeight(); + GnomeSurface surface(widget); + + context->paragraph->draw(&surface, firstLine, (maxLines < lastLine)? maxLines : lastLine); + } + + return TRUE; +} + +GtkWidget *newSample(const gchar *fileName) +{ + Context *context = new Context(); + + context->width = 600; + context->height = 400; + context->paragraph = Paragraph::paragraphFactory(fileName, font, guiSupport); + + gchar *title = prettyTitle(fileName); + GtkWidget *app = gnome_app_new("gnomeLayout", title); + + gtk_object_set_data(GTK_OBJECT(app), "context", context); + + gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400); + + gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app); + + gtk_signal_connect(GTK_OBJECT(app), "delete_event", + GTK_SIGNAL_FUNC(eventDelete), NULL); + + GtkWidget *area = gtk_drawing_area_new(); + gtk_object_set_data(GTK_OBJECT(app), "area", area); + + GtkStyle *style = gtk_style_copy(gtk_widget_get_style(area)); + + for (int i = 0; i < 5; i += 1) { + style->fg[i] = style->white; + } + + gtk_widget_set_style(area, style); + + gnome_app_set_contents(GNOME_APP(app), area); + + gtk_signal_connect(GTK_OBJECT(area), + "expose_event", + GTK_SIGNAL_FUNC(eventExpose), + context); + + gtk_signal_connect(GTK_OBJECT(area), + "configure_event", + GTK_SIGNAL_FUNC(eventConfigure), + context); + + appList = g_slist_prepend(appList, app); + + g_free(title); + + return app; +} + +void closeSample(GtkWidget *app) +{ + Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); + + if (context->paragraph != NULL) { + delete context->paragraph; + } + + delete context; + + appList = g_slist_remove(appList, app); + + gtk_widget_destroy(app); + + if (appList == NULL) { + gtk_main_quit(); + } +} + +int main (int argc, char *argv[]) +{ + LEErrorCode fontStatus = LE_NO_ERROR; + poptContext ptctx; + GtkWidget *app; + + FT_Init_FreeType(&engine); + + gnome_init_with_popt_table("gnomelayout", "0.1", argc, argv, NULL, 0, &ptctx); + + guiSupport = new GnomeGUISupport(); + fontMap = new GnomeFontMap(engine, "FontMap.Gnome", 24, guiSupport, fontStatus); + font = new ScriptCompositeFontInstance(fontMap); + + if (LE_FAILURE(fontStatus)) { + FT_Done_FreeType(engine); + return 1; + } + + const char *defaultArgs[] = {"Sample.txt", NULL}; + const char **args = poptGetArgs(ptctx); + + if (args == NULL) { + args = defaultArgs; + } + + for (int i = 0; args[i] != NULL; i += 1) { + app = newSample(args[i]); + + gtk_widget_show_all(app); + } + + poptFreeContext(ptctx); + + gtk_main(); + + delete font; + delete guiSupport; + + FT_Done_FreeType(engine); + + exit(0); +} diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/gsupport.h b/Build/source/libs/icu/icu-50.1/samples/layout/gsupport.h new file mode 100644 index 00000000000..26f33b4c064 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/gsupport.h @@ -0,0 +1,14 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __GSUPPORT_H +#define __GSUPPORT_H + +typedef void gs_guiSupport; + +void gs_postErrorMessage(gs_guiSupport *guiSupport, const char *message, const char *title); + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/layout.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/layout.cpp new file mode 100644 index 00000000000..8501757edb9 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/layout.cpp @@ -0,0 +1,358 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: Layout.cpp + * + * created on: 08/03/2000 + * created by: Eric R. Mader + */ + +#include <windows.h> +#include <stdio.h> + +#include "paragraph.h" + +#include "GDIGUISupport.h" +#include "GDIFontMap.h" +#include "UnicodeReader.h" +#include "ScriptCompositeFontInstance.h" + +#include "resource.h" + +#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0]) + +struct Context +{ + le_int32 width; + le_int32 height; + Paragraph *paragraph; +}; + +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + +#define APP_NAME "LayoutSample" + +TCHAR szAppName[] = TEXT(APP_NAME); + +void PrettyTitle(HWND hwnd, char *fileName) +{ + char title[MAX_PATH + 64]; + + sprintf(title, "%s - %s", APP_NAME, fileName); + + SetWindowTextA(hwnd, title); +} + +void InitParagraph(HWND hwnd, Context *context) +{ + SCROLLINFO si; + + if (context->paragraph != NULL) { + // FIXME: does it matter what we put in the ScrollInfo + // if the window's been minimized? + if (context->width > 0 && context->height > 0) { + context->paragraph->breakLines(context->width, context->height); + } + + si.cbSize = sizeof si; + si.fMask = SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL; + si.nMin = 0; + si.nMax = context->paragraph->getLineCount() - 1; + si.nPage = context->height / context->paragraph->getLineHeight(); + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + } +} + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) +{ + HWND hwnd; + HACCEL hAccel; + MSG msg; + WNDCLASS wndclass; + LEErrorCode status = LE_NO_ERROR; + + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = WndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = sizeof(LONG); + wndclass.hInstance = hInstance; + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); + wndclass.lpszMenuName = szAppName; + wndclass.lpszClassName = szAppName; + + if (!RegisterClass(&wndclass)) { + MessageBox(NULL, TEXT("This demo only runs on Windows 2000!"), szAppName, MB_ICONERROR); + + return 0; + } + + hAccel = LoadAccelerators(hInstance, szAppName); + + hwnd = CreateWindow(szAppName, NULL, + WS_OVERLAPPEDWINDOW | WS_VSCROLL, + CW_USEDEFAULT, CW_USEDEFAULT, + 600, 400, + NULL, NULL, hInstance, NULL); + + ShowWindow(hwnd, iCmdShow); + UpdateWindow(hwnd); + + while (GetMessage(&msg, NULL, 0, 0)) { + if (!TranslateAccelerator(hwnd, hAccel, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + UnregisterClass(szAppName, hInstance); + return msg.wParam; +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + Context *context; + static le_int32 windowCount = 0; + static GDIFontMap *fontMap = NULL; + static GDISurface *surface = NULL; + static GDIGUISupport *guiSupport = new GDIGUISupport(); + static ScriptCompositeFontInstance *font = NULL; + + switch (message) { + case WM_CREATE: + { + LEErrorCode fontStatus = LE_NO_ERROR; + + hdc = GetDC(hwnd); + surface = new GDISurface(hdc); + + fontMap = new GDIFontMap(surface, "FontMap.GDI", 24, guiSupport, fontStatus); + font = new ScriptCompositeFontInstance(fontMap); + + if (LE_FAILURE(fontStatus)) { + ReleaseDC(hwnd, hdc); + return -1; + } + + context = new Context(); + + context->width = 600; + context->height = 400; + + context->paragraph = Paragraph::paragraphFactory("Sample.txt", font, guiSupport); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) context); + + windowCount += 1; + ReleaseDC(hwnd, hdc); + + PrettyTitle(hwnd, "Sample.txt"); + return 0; + } + + case WM_SIZE: + { + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + context->width = LOWORD(lParam); + context->height = HIWORD(lParam); + + InitParagraph(hwnd, context); + return 0; + } + + case WM_VSCROLL: + { + SCROLLINFO si; + le_int32 vertPos; + + si.cbSize = sizeof si; + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, &si); + + vertPos = si.nPos; + + switch (LOWORD(wParam)) + { + case SB_TOP: + si.nPos = si.nMin; + break; + + case SB_BOTTOM: + si.nPos = si.nMax; + break; + + case SB_LINEUP: + si.nPos -= 1; + break; + + case SB_LINEDOWN: + si.nPos += 1; + break; + + case SB_PAGEUP: + si.nPos -= si.nPage; + break; + + case SB_PAGEDOWN: + si.nPos += si.nPage; + break; + + case SB_THUMBTRACK: + si.nPos = si.nTrackPos; + break; + + default: + break; + } + + si.fMask = SIF_POS; + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + GetScrollInfo(hwnd, SB_VERT, &si); + + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + + if (context->paragraph != NULL && si.nPos != vertPos) { + ScrollWindow(hwnd, 0, context->paragraph->getLineHeight() * (vertPos - si.nPos), NULL, NULL); + UpdateWindow(hwnd); + } + + return 0; + } + + case WM_PAINT: + { + PAINTSTRUCT ps; + SCROLLINFO si; + le_int32 firstLine, lastLine; + + hdc = BeginPaint(hwnd, &ps); + SetBkMode(hdc, TRANSPARENT); + + si.cbSize = sizeof si; + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, &si); + + firstLine = si.nPos; + + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + + if (context->paragraph != NULL) { + surface->setHDC(hdc); + + // NOTE: si.nPos + si.nPage may include a partial line at the bottom + // of the window. We need this because scrolling assumes that the + // partial line has been painted. + lastLine = min (si.nPos + (le_int32) si.nPage, context->paragraph->getLineCount() - 1); + + context->paragraph->draw(surface, firstLine, lastLine); + } + + EndPaint(hwnd, &ps); + return 0; + } + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDM_FILE_OPEN: + { + OPENFILENAMEA ofn; + char szFileName[MAX_PATH], szTitleName[MAX_PATH]; + static char szFilter[] = "Text Files (.txt)\0*.txt\0" + "All Files (*.*)\0*.*\0\0"; + + ofn.lStructSize = sizeof (OPENFILENAMEA); + ofn.hwndOwner = hwnd; + ofn.hInstance = NULL; + ofn.lpstrFilter = szFilter; + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 0; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = szTitleName; + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle = NULL; + ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + ofn.nFileOffset = 0; + ofn.nFileExtension = 0; + ofn.lpstrDefExt = "txt"; + ofn.lCustData = 0L; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; + + szFileName[0] = '\0'; + + if (GetOpenFileNameA(&ofn)) { + hdc = GetDC(hwnd); + surface->setHDC(hdc); + + Paragraph *newParagraph = Paragraph::paragraphFactory(szFileName, font, guiSupport); + + if (newParagraph != NULL) { + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + + if (context->paragraph != NULL) { + delete context->paragraph; + } + + context->paragraph = newParagraph; + InitParagraph(hwnd, context); + PrettyTitle(hwnd, szTitleName); + InvalidateRect(hwnd, NULL, TRUE); + + } + } + + //ReleaseDC(hwnd, hdc); + + return 0; + } + + case IDM_FILE_EXIT: + case IDM_FILE_CLOSE: + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; + + case IDM_HELP_ABOUTLAYOUTSAMPLE: + MessageBox(hwnd, TEXT("Windows Layout Sample 0.1\n") + TEXT("Copyright (C) 1998-2005 By International Business Machines Corporation and others.\n") + TEXT("Author: Eric Mader"), + szAppName, MB_ICONINFORMATION | MB_OK); + return 0; + + } + break; + + + case WM_DESTROY: + { + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + + if (context != NULL && context->paragraph != NULL) { + delete context->paragraph; + } + + delete context; + + if (--windowCount <= 0) { + delete font; + delete surface; + + PostQuitMessage(0); + } + + return 0; + } + + default: + return DefWindowProc(hwnd, message, wParam, lParam); + } + + return 0; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/layout.sln b/Build/source/libs/icu/icu-50.1/samples/layout/layout.sln new file mode 100644 index 00000000000..7ee452a33b5 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/layout.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "layout", "layout.vcxproj", "{497500ED-DE1D-4B20-B529-F41B5A0FBEEB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Debug|Win32.ActiveCfg = Debug|Win32 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Debug|Win32.Build.0 = Debug|Win32 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Debug|x64.ActiveCfg = Debug|x64 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Debug|x64.Build.0 = Debug|x64 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|Win32.ActiveCfg = Release|Win32 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|Win32.Build.0 = Release|Win32 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|x64.ActiveCfg = Release|x64 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/layout.vcxproj b/Build/source/libs/icu/icu-50.1/samples/layout/layout.vcxproj new file mode 100644 index 00000000000..bc5e5464338 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/layout.vcxproj @@ -0,0 +1,267 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{497500ED-DE1D-4B20-B529-F41B5A0FBEEB}</ProjectGuid> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Midl> + <TypeLibraryName>.\x86\Release/layout.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <AdditionalIncludeDirectories>..\..\..\include;..\..\..\include\layout;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;WIN32;UNICODE;_CRT_SECURE_NO_DEPRECATE;LE_USE_CMEMORY;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderOutputFile>.\x86\Release/layout.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation> + <ObjectFileName>.\x86\Release/</ObjectFileName> + <ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>..\..\..\lib\iculx.lib;..\..\..\lib\icule.lib;..\..\..\lib\icuuc.lib;..\..\..\lib\icuin.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>.\x86\Release/layout.exe</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <ProgramDatabaseFile>.\x86\Release/layout.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + <TypeLibraryName>.\x64\Release/layout.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <AdditionalIncludeDirectories>..\..\..\include;..\..\..\include\layout;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;WIN64;WIN32;UNICODE;_CRT_SECURE_NO_DEPRECATE;LE_USE_CMEMORY;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderOutputFile>.\x64\Release/layout.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation> + <ObjectFileName>.\x64\Release/</ObjectFileName> + <ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>..\..\..\lib64\iculx.lib;..\..\..\lib64\icule.lib;..\..\..\lib64\icuuc.lib;..\..\..\lib64\icuin.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>.\x64\Release/layout.exe</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <ProgramDatabaseFile>.\x64\Release/layout.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Midl> + <TypeLibraryName>.\x86\Debug/layout.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\..\..\include;..\..\..\include\layout;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;WIN32;UNICODE;LE_USE_CMEMORY;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderOutputFile>.\x86\Debug/layout.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation> + <ObjectFileName>.\x86\Debug/</ObjectFileName> + <ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>..\..\..\lib\iculxd.lib;..\..\..\lib\iculed.lib;..\..\..\lib\icuucd.lib;..\..\..\lib\icuind.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>.\x86\Debug/layout.exe</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>.\x86\Debug/layout.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + <TypeLibraryName>.\x64\Debug/layout.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\..\..\include;..\..\..\include\layout;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_DEBUG;WIN64;WIN32;UNICODE;LE_USE_CMEMORY;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderOutputFile>.\x64\Debug/layout.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation> + <ObjectFileName>.\x64\Debug/</ObjectFileName> + <ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>..\..\..\lib64\iculxd.lib;..\..\..\lib64\iculed.lib;..\..\..\lib64\icuucd.lib;..\..\..\lib64\icuind.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>.\x64\Debug/layout.exe</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>.\x64\Debug/layout.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="cmaps.cpp" /> + <ClCompile Include="FontMap.cpp" /> + <ClCompile Include="FontTableCache.cpp" /> + <ClCompile Include="GDIFontInstance.cpp" /> + <ClCompile Include="GDIFontMap.cpp" /> + <ClCompile Include="GDIGUISupport.cpp" /> + <ClCompile Include="layout.cpp" /> + <ClCompile Include="paragraph.cpp" /> + <ClCompile Include="ScriptCompositeFontInstance.cpp" /> + <ClCompile Include="UnicodeReader.cpp" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="LayoutSample.rc" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="cmaps.h" /> + <ClInclude Include="FontMap.h" /> + <ClInclude Include="FontTableCache.h" /> + <ClInclude Include="GDIFontInstance.h" /> + <ClInclude Include="GDIFontMap.h" /> + <ClInclude Include="GDIGUISupport.h" /> + <ClInclude Include="GUISupport.h" /> + <ClInclude Include="paragraph.h" /> + <ClInclude Include="RenderingSurface.h" /> + <ClInclude Include="resource.h" /> + <ClInclude Include="ScriptCompositeFontInstance.h" /> + <ClInclude Include="sfnt.h" /> + <ClInclude Include="UnicodeReader.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/layout.vcxproj.filters b/Build/source/libs/icu/icu-50.1/samples/layout/layout.vcxproj.filters new file mode 100644 index 00000000000..4a28bdf48af --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/layout.vcxproj.filters @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{d95d859b-6ae7-4ac2-953c-511411f74b77}</UniqueIdentifier> + <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{8e82936c-dd21-49c1-9174-d88411b4b9c7}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{d7b63b8f-73c9-48ca-b0cb-fa6a537901c4}</UniqueIdentifier> + <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="cmaps.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="FontMap.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="FontTableCache.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="GDIFontInstance.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="GDIFontMap.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="GDIGUISupport.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="layout.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="paragraph.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="ScriptCompositeFontInstance.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="UnicodeReader.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="LayoutSample.rc"> + <Filter>Source Files</Filter> + </ResourceCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="cmaps.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="FontMap.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="FontTableCache.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="GDIFontInstance.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="GDIFontMap.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="GDIGUISupport.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="GUISupport.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="paragraph.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="RenderingSurface.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="ScriptCompositeFontInstance.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="sfnt.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="UnicodeReader.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/paragraph.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/paragraph.cpp new file mode 100644 index 00000000000..65d3e368423 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/paragraph.cpp @@ -0,0 +1,278 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: Paragraph.cpp + * + * created on: 09/06/2000 + * created by: Eric R. Mader + */ + +#include "unicode/utypes.h" +#include "unicode/uchar.h" +#include "unicode/ubidi.h" +#include "unicode/ustring.h" + +#include "layout/ParagraphLayout.h" + +#include "RenderingSurface.h" + +#include "paragraph.h" +#include "UnicodeReader.h" + +#define MARGIN 10 +#define LINE_GROW 32 +#define PARA_GROW 8 + +#define CH_LF 0x000A +#define CH_CR 0x000D +#define CH_LSEP 0x2028 +#define CH_PSEP 0x2029 + +static LEUnicode *skipLineEnd(LEUnicode *ptr) +{ + if (ptr[0] == CH_CR && ptr[1] == CH_LF) { + ptr += 1; + } + + return ptr + 1; +} + +static le_int32 findRun(const RunArray *runArray, le_int32 offset) +{ + le_int32 runCount = runArray->getCount(); + + for (le_int32 run = 0; run < runCount; run += 1) { + if (runArray->getLimit(run) > offset) { + return run; + } + } + + return -1; +} + +static void subsetFontRuns(const FontRuns *fontRuns, le_int32 start, le_int32 limit, FontRuns *sub) +{ + le_int32 startRun = findRun(fontRuns, start); + le_int32 endRun = findRun(fontRuns, limit - 1); + + sub->reset(); + + for (le_int32 run = startRun; run <= endRun; run += 1) { + const LEFontInstance *runFont = fontRuns->getFont(run); + le_int32 runLimit = fontRuns->getLimit(run) - start; + + if (run == endRun) { + runLimit = limit - start; + } + + sub->add(runFont, runLimit); + } +} + +Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns *fontRuns, LEErrorCode &status) + : fParagraphLayout(NULL), fParagraphCount(0), fParagraphMax(PARA_GROW), fParagraphGrow(PARA_GROW), + fLineCount(0), fLinesMax(LINE_GROW), fLinesGrow(LINE_GROW), fLines(NULL), fChars(NULL), + fLineHeight(-1), fAscent(-1), fWidth(-1), fHeight(-1), fParagraphLevel(UBIDI_DEFAULT_LTR) +{ + static const LEUnicode separators[] = {CH_LF, CH_CR, CH_LSEP, CH_PSEP, 0x0000}; + + if (LE_FAILURE(status)) { + return; + } + + le_int32 ascent = 0; + le_int32 descent = 0; + le_int32 leading = 0; + + LocaleRuns *locales = NULL; + FontRuns fr(0); + + fLines = LE_NEW_ARRAY(const ParagraphLayout::Line *, fLinesMax); + fParagraphLayout = LE_NEW_ARRAY(ParagraphLayout *, fParagraphMax); + + fChars = LE_NEW_ARRAY(LEUnicode, charCount + 1); + LE_ARRAY_COPY(fChars, chars, charCount); + fChars[charCount] = 0; + + LEUnicode *pStart = &fChars[0]; + + while (*pStart != 0) { + LEUnicode *pEnd = u_strpbrk(pStart, separators); + le_int32 pAscent, pDescent, pLeading; + ParagraphLayout *paragraphLayout = NULL; + + if (pEnd == NULL) { + pEnd = &fChars[charCount]; + } + + if (pEnd != pStart) { + subsetFontRuns(fontRuns, pStart - fChars, pEnd - fChars, &fr); + + paragraphLayout = new ParagraphLayout(pStart, pEnd - pStart, &fr, NULL, NULL, locales, fParagraphLevel, FALSE, status); + + if (LE_FAILURE(status)) { + break; // return? something else? + } + + if (fParagraphLevel == UBIDI_DEFAULT_LTR) { + fParagraphLevel = paragraphLayout->getParagraphLevel(); + } + + pAscent = paragraphLayout->getAscent(); + pDescent = paragraphLayout->getDescent(); + pLeading = paragraphLayout->getLeading(); + + if (pAscent > ascent) { + ascent = pAscent; + } + + if (pDescent > descent) { + descent = pDescent; + } + + if (pLeading > leading) { + leading = pLeading; + } + } + + if (fParagraphCount >= fParagraphMax) { + fParagraphLayout = (ParagraphLayout **) LE_GROW_ARRAY(fParagraphLayout, fParagraphMax + fParagraphGrow); + fParagraphMax += fParagraphGrow; + } + + fParagraphLayout[fParagraphCount++] = paragraphLayout; + + if (*pEnd == 0) { + break; + } + + pStart = skipLineEnd(pEnd); + } + + fLineHeight = ascent + descent + leading; + fAscent = ascent; +} + +Paragraph::~Paragraph() +{ + for (le_int32 line = 0; line < fLineCount; line += 1) { + delete /*(LineInfo *)*/ fLines[line]; + } + + LE_DELETE_ARRAY(fLines); + delete fParagraphLayout; + LE_DELETE_ARRAY(fChars); +} + +void Paragraph::addLine(const ParagraphLayout::Line *line) +{ + if (fLineCount >= fLinesMax) { + fLines = (const ParagraphLayout::Line **) LE_GROW_ARRAY(fLines, fLinesMax + fLinesGrow); + fLinesMax += fLinesGrow; + } + + fLines[fLineCount++] = line; +} + +void Paragraph::breakLines(le_int32 width, le_int32 height) +{ + fHeight = height; + + // don't re-break if the width hasn't changed + if (fWidth == width) { + return; + } + + fWidth = width; + + float lineWidth = (float) (width - 2 * MARGIN); + const ParagraphLayout::Line *line; + + // Free the old LineInfo's... + for (le_int32 li = 0; li < fLineCount; li += 1) { + delete fLines[li]; + } + + fLineCount = 0; + + for (le_int32 p = 0; p < fParagraphCount; p += 1) { + ParagraphLayout *paragraphLayout = fParagraphLayout[p]; + + if (paragraphLayout != NULL) { + paragraphLayout->reflow(); + while ((line = paragraphLayout->nextLine(lineWidth)) != NULL) { + addLine(line); + } + } else { + addLine(NULL); + } + } +} + +void Paragraph::draw(RenderingSurface *surface, le_int32 firstLine, le_int32 lastLine) +{ + le_int32 li, x, y; + + x = MARGIN; + y = fAscent; + + for (li = firstLine; li <= lastLine; li += 1) { + const ParagraphLayout::Line *line = fLines[li]; + + if (line != NULL) { + le_int32 runCount = line->countRuns(); + le_int32 run; + + if (fParagraphLevel == UBIDI_RTL) { + le_int32 lastX = line->getWidth(); + + x = (fWidth - lastX - MARGIN); + } + + + for (run = 0; run < runCount; run += 1) { + const ParagraphLayout::VisualRun *visualRun = line->getVisualRun(run); + le_int32 glyphCount = visualRun->getGlyphCount(); + const LEFontInstance *font = visualRun->getFont(); + const LEGlyphID *glyphs = visualRun->getGlyphs(); + const float *positions = visualRun->getPositions(); + + surface->drawGlyphs(font, glyphs, glyphCount, positions, x, y, fWidth, fHeight); + } + } + + y += fLineHeight; + } +} + +Paragraph *Paragraph::paragraphFactory(const char *fileName, const LEFontInstance *font, GUISupport *guiSupport) +{ + LEErrorCode status = LE_NO_ERROR; + le_int32 charCount; + const UChar *text = UnicodeReader::readFile(fileName, guiSupport, charCount); + Paragraph *result = NULL; + + if (text == NULL) { + return NULL; + } + + FontRuns fontRuns(0); + + fontRuns.add(font, charCount); + + result = new Paragraph(text, charCount, &fontRuns, status); + + if (LE_FAILURE(status)) { + delete result; + result = NULL; + } + + LE_DELETE_ARRAY(text); + + return result; +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/paragraph.h b/Build/source/libs/icu/icu-50.1/samples/layout/paragraph.h new file mode 100644 index 00000000000..c51c9f41ef2 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/paragraph.h @@ -0,0 +1,88 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: Paragraph.h + * + * created on: 09/06/2000 + * created by: Eric R. Mader + */ +#ifndef __PARAGRAPH_H +#define __PARAGRAPH_H + +#include "unicode/utypes.h" +#include "unicode/ubidi.h" + +#include "layout/LEFontInstance.h" +#include "layout/ParagraphLayout.h" + +#include "GUISupport.h" +#include "RenderingSurface.h" + +U_NAMESPACE_USE + +#define MARGIN 10 + +#if 0 +class LineInfo; +#endif + +class Paragraph +{ +public: + Paragraph(const LEUnicode chars[], le_int32 charCount, const FontRuns *fontRuns, LEErrorCode &status); + + ~Paragraph(); + + le_int32 getAscent(); + le_int32 getLineHeight(); + le_int32 getLineCount(); + void breakLines(le_int32 width, le_int32 height); + void draw(RenderingSurface *surface, le_int32 firstLine, le_int32 lastLine); + + static Paragraph *paragraphFactory(const char *fileName, const LEFontInstance *font, GUISupport *guiSupport); + +private: + void addLine(const ParagraphLayout::Line *line); + + ParagraphLayout **fParagraphLayout; + + le_int32 fParagraphCount; + le_int32 fParagraphMax; + le_int32 fParagraphGrow; + + le_int32 fLineCount; + le_int32 fLinesMax; + le_int32 fLinesGrow; + + const ParagraphLayout::Line **fLines; + LEUnicode *fChars; + + le_int32 fLineHeight; + le_int32 fAscent; + le_int32 fWidth; + le_int32 fHeight; + UBiDiLevel fParagraphLevel; +}; + +inline le_int32 Paragraph::getLineHeight() +{ + return fLineHeight; +} + +inline le_int32 Paragraph::getLineCount() +{ + return fLineCount; +} + +inline le_int32 Paragraph::getAscent() +{ + return fAscent; +} + +#endif + + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/pflow.c b/Build/source/libs/icu/icu-50.1/samples/layout/pflow.c new file mode 100644 index 00000000000..80450ad20be --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/pflow.c @@ -0,0 +1,381 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include "unicode/utypes.h" +#include "unicode/uchar.h" +#include "unicode/ubidi.h" +#include "unicode/ustring.h" + +#include "layout/LETypes.h" + +#include "layout/loengine.h" +#include "layout/playout.h" +#include "layout/plruns.h" + +#include "pflow.h" + +#include "arraymem.h" +#include "ucreader.h" + +/* + * Move the line below out of this comment + * to add a locale run to the pl_paragraphs + * that are created. +#define TEST_LOCALE "zh_TW" + */ + +#define MARGIN 10 +#define LINE_GROW 32 +#define PARA_GROW 8 + +#define CH_LF 0x000A +#define CH_CR 0x000D +#define CH_LSEP 0x2028 +#define CH_PSEP 0x2029 + +struct pf_object +{ + pl_paragraph **fParagraphLayout; + + le_int32 fParagraphCount; + le_int32 fParagraphMax; + le_int32 fParagraphGrow; + + le_int32 fLineCount; + le_int32 fLinesMax; + le_int32 fLinesGrow; + + pl_line **fLines; + + LEUnicode *fChars; + + le_int32 fLineHeight; + le_int32 fAscent; + le_int32 fWidth; + le_int32 fHeight; + UBiDiLevel fParagraphLevel; +}; + +typedef struct pf_object pf_object; + + +static LEUnicode *skipLineEnd(LEUnicode *ptr) +{ + if (ptr[0] == CH_CR && ptr[1] == CH_LF) { + ptr += 1; + } + + return ptr + 1; +} + +static le_int32 findFontRun(const pl_fontRuns *fontRuns, le_int32 offset) +{ + le_int32 runCount = pl_getFontRunCount(fontRuns); + le_int32 run; + + for (run = 0; run < runCount; run += 1) { + if (pl_getFontRunLimit(fontRuns, run) > offset) { + return run; + } + } + + return -1; +} + +static void subsetFontRuns(const pl_fontRuns *fontRuns, le_int32 start, le_int32 limit, pl_fontRuns *sub) +{ + le_int32 startRun = findFontRun(fontRuns, start); + le_int32 endRun = findFontRun(fontRuns, limit - 1); + le_int32 run; + + pl_resetFontRuns(sub); + + for (run = startRun; run <= endRun; run += 1) { + const le_font *runFont = pl_getFontRunFont(fontRuns, run); + le_int32 runLimit = pl_getFontRunLimit(fontRuns, run) - start; + + if (run == endRun) { + runLimit = limit - start; + } + + pl_addFontRun(sub, runFont, runLimit); + } +} + +pf_flow *pf_create(const LEUnicode chars[], le_int32 charCount, const pl_fontRuns *fontRuns, LEErrorCode *status) +{ + pf_object *flow; + le_int32 ascent = 0; + le_int32 descent = 0; + le_int32 leading = 0; + pl_localeRuns *locales = NULL; + pl_fontRuns *fr; + LEUnicode *pStart; + static const LEUnicode separators[] = {CH_LF, CH_CR, CH_LSEP, CH_PSEP, 0x0000}; + + if (LE_FAILURE(*status)) { + return NULL; + } + + flow = NEW_ARRAY(pf_object, 1); + + flow->fParagraphLayout = NULL; + flow->fParagraphCount = 0; + flow->fParagraphMax = PARA_GROW; + flow->fParagraphGrow = PARA_GROW; + flow->fLineCount = 0; + flow->fLinesMax = LINE_GROW; + flow->fLinesGrow = LINE_GROW; + flow->fLines = NULL; + flow->fChars = NULL; + flow->fLineHeight = -1; + flow->fAscent = -1; + flow->fWidth = -1; + flow->fHeight = -1; + flow->fParagraphLevel = UBIDI_DEFAULT_LTR; + + fr = pl_openEmptyFontRuns(0); + +#ifdef TEST_LOCALE + locales = pl_openEmptyLocaleRuns(0); +#endif + + flow->fLines = NEW_ARRAY(pl_line *, flow->fLinesMax); + flow->fParagraphLayout = NEW_ARRAY(pl_paragraph *, flow->fParagraphMax); + + flow->fChars = NEW_ARRAY(LEUnicode, charCount + 1); + LE_ARRAY_COPY(flow->fChars, chars, charCount); + flow->fChars[charCount] = 0; + + pStart = &flow->fChars[0]; + + while (*pStart != 0) { + LEUnicode *pEnd = u_strpbrk(pStart, separators); + le_int32 pAscent, pDescent, pLeading; + pl_paragraph *paragraphLayout = NULL; + + if (pEnd == NULL) { + pEnd = &flow->fChars[charCount]; + } + + if (pEnd != pStart) { + subsetFontRuns(fontRuns, pStart - flow->fChars, pEnd - flow->fChars, fr); + +#ifdef TEST_LOCALE + pl_resetLocaleRuns(locales); + pl_addLocaleRun(locales, TEST_LOCALE, pEnd - pStart); +#endif + + paragraphLayout = pl_create(pStart, pEnd - pStart, fr, NULL, NULL, locales, flow->fParagraphLevel, FALSE, status); + + if (LE_FAILURE(*status)) { + break; /* return? something else? */ + } + + if (flow->fParagraphLevel == UBIDI_DEFAULT_LTR) { + flow->fParagraphLevel = pl_getParagraphLevel(paragraphLayout); + } + + pAscent = pl_getAscent(paragraphLayout); + pDescent = pl_getDescent(paragraphLayout); + pLeading = pl_getLeading(paragraphLayout); + + if (pAscent > ascent) { + ascent = pAscent; + } + + if (pDescent > descent) { + descent = pDescent; + } + + if (pLeading > leading) { + leading = pLeading; + } + } + + if (flow->fParagraphCount >= flow->fParagraphMax) { + flow->fParagraphLayout = (pl_paragraph **) GROW_ARRAY(flow->fParagraphLayout, flow->fParagraphMax + flow->fParagraphGrow); + flow->fParagraphMax += flow->fParagraphGrow; + } + + flow->fParagraphLayout[flow->fParagraphCount++] = paragraphLayout; + + if (*pEnd == 0) { + break; + } + + pStart = skipLineEnd(pEnd); + } + + flow->fLineHeight = ascent + descent + leading; + flow->fAscent = ascent; + + pl_closeLocaleRuns(locales); + pl_closeFontRuns(fr); + + return (pf_flow *) flow; +} + +void pf_close(pf_flow *flow) +{ + pf_object *obj = (pf_object *) flow; + le_int32 i; + + for (i = 0; i < obj->fLineCount; i += 1) { + DELETE_ARRAY(obj->fLines[i]); + } + + DELETE_ARRAY(obj->fLines); + + for (i = 0; i < obj->fParagraphCount; i += 1) { + pl_close(obj->fParagraphLayout[i]); + } + + DELETE_ARRAY(obj->fParagraphLayout); + + DELETE_ARRAY(obj->fChars); + + DELETE_ARRAY(obj); +} + + +le_int32 pf_getAscent(pf_flow *flow) +{ + pf_object *obj = (pf_object *) flow; + + return obj->fAscent; +} + +le_int32 pf_getLineHeight(pf_flow *flow) +{ + pf_object *obj = (pf_object *) flow; + + return obj->fLineHeight; +} + +le_int32 pf_getLineCount(pf_flow *flow) +{ + pf_object *obj = (pf_object *) flow; + + return obj->fLineCount; +} + +static void addLine(pf_object *obj, pl_line *line) +{ + if (obj->fLineCount >= obj->fLinesMax) { + obj->fLines = (pl_line **) GROW_ARRAY(obj->fLines, obj->fLinesMax + obj->fLinesGrow); + obj->fLinesMax += obj->fLinesGrow; + } + + obj->fLines[obj->fLineCount++] = line; +} + +void pf_breakLines(pf_flow *flow, le_int32 width, le_int32 height) +{ + pf_object *obj = (pf_object *) flow; + le_int32 li, p; + float lineWidth; + pl_line *line; + + obj->fHeight = height; + + /* don't re-break if the width hasn't changed */ + if (obj->fWidth == width) { + return; + } + + obj->fWidth = width; + + lineWidth = (float) (width - 2 * MARGIN); + + /* Free the old Lines... */ + for (li = 0; li < obj->fLineCount; li += 1) { + pl_closeLine(obj->fLines[li]); + } + + obj->fLineCount = 0; + + for (p = 0; p < obj->fParagraphCount; p += 1) { + pl_paragraph *paragraphLayout = obj->fParagraphLayout[p]; + + if (paragraphLayout != NULL) { + pl_reflow(paragraphLayout); + while ((line = pl_nextLine(paragraphLayout, lineWidth)) != NULL) { + addLine(obj, line); + } + } else { + addLine(obj, NULL); + } + } +} + +void pf_draw(pf_flow *flow, rs_surface *surface, le_int32 firstLine, le_int32 lastLine) +{ + pf_object *obj = (pf_object *) flow; + le_int32 li, x, y; + + x = MARGIN; + y = obj->fAscent; + + for (li = firstLine; li <= lastLine; li += 1) { + const pl_line *line = obj->fLines[li]; + + if (line != NULL) { + le_int32 runCount = pl_countLineRuns(line); + le_int32 run; + + if (obj->fParagraphLevel == UBIDI_RTL) { + le_int32 lastX = pl_getLineWidth(line); + + x = (obj->fWidth - lastX - MARGIN); + } + + + for (run = 0; run < runCount; run += 1) { + const pl_visualRun *visualRun = pl_getLineVisualRun(line, run); + le_int32 glyphCount = pl_getVisualRunGlyphCount(visualRun); + const le_font *font = pl_getVisualRunFont(visualRun); + const LEGlyphID *glyphs = pl_getVisualRunGlyphs(visualRun); + const float *positions = pl_getVisualRunPositions(visualRun); + + rs_drawGlyphs(surface, font, glyphs, glyphCount, positions, x, y, obj->fWidth, obj->fHeight); + } + } + + y += obj->fLineHeight; + } +} + +pf_flow *pf_factory(const char *fileName, const le_font *font, gs_guiSupport *guiSupport) +{ + LEErrorCode status = LE_NO_ERROR; + le_int32 charCount; + const UChar *text = uc_readFile(fileName, guiSupport, &charCount); + pl_fontRuns *fontRuns; + pf_flow *result = NULL; + + if (text == NULL) { + return NULL; + } + + fontRuns = pl_openEmptyFontRuns(0); + + pl_addFontRun(fontRuns, font, charCount); + + result = pf_create(text, charCount, fontRuns, &status); + + if (LE_FAILURE(status)) { + pf_close(result); + result = NULL; + } + + pl_closeFontRuns(fontRuns); + + DELETE_ARRAY(text); + + return result; +} + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/pflow.h b/Build/source/libs/icu/icu-50.1/samples/layout/pflow.h new file mode 100644 index 00000000000..7e0b7f313d8 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/pflow.h @@ -0,0 +1,33 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __PFLOW_H +#define __PFLOW_H + +#include "unicode/utypes.h" +#include "layout/LETypes.h" + +#include "layout/plruns.h" +#include "layout/playout.h" + +#include "gsupport.h" +#include "rsurface.h" + +typedef void pf_flow; + +pf_flow *pf_create(const LEUnicode chars[], le_int32 charCount, const pl_fontRuns *fontRuns, LEErrorCode *status); + +void pf_close(pf_flow *flow); + +le_int32 pf_getAscent(pf_flow *flow); +le_int32 pf_getLineHeight(pf_flow *flow); +le_int32 pf_getLineCount(pf_flow *flow); +void pf_breakLines(pf_flow *flow, le_int32 width, le_int32 height); +void pf_draw(pf_flow *flow, rs_surface *surface, le_int32 firstLine, le_int32 lastLine); + +pf_flow *pf_factory(const char *fileName, const le_font *font, gs_guiSupport *guiSupport); + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/readme.html b/Build/source/libs/icu/icu-50.1/samples/layout/readme.html new file mode 100644 index 00000000000..1db4e306831 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/readme.html @@ -0,0 +1,161 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> + <meta name="COPYRIGHT" content= + "Copyright (c) 2001-2010 IBM Corporation and others. All Rights Reserved." /> + <meta name="Author" content="Eric Mader" /> + + <title>Readme file for the ICU LayoutEngine demo</title> +</head> + +<body> + <h2>What is the layout demo?</h2> + + <p>The layout demo displays a paragraph of text that is laid out using the + LayoutEngine. There are two versions of this demo, "layout.exe" which runs on + Windows 2000, and "gnomelayout" which runs on Linux. Both programs read a + file containing the Unicode text to display, and a file that says which font + to use to display each script.</p> + + <h2>How do I build the layout demo?</h2>First, you need to build ICU, + including the LayoutEngine. + + <p>On Windows, the layout project should be listed as a dependency of all, so + layout will build when you build all. If it doesn't for some reason, just + select the layout project in the project toolbar and build it.</p> + + <p>On Linux systems, you need to add the "--enable-layout=yes" option when + you invoke the runConfigureICU script. When you've done that, layout should + build when you do "make all install"</p> + + <p>To build the demo on Windows, just open the layout project in + <icu>\source\samples\layout and build it.</p> + + <p>On Linux systems, connect to <top-build-dir>/samples/layout and do + "make all". To build the layout demo on Linux, you'll need the + gnome-libs-devel and freetype-devel packages, which should be part of your + Linux distribution. The demo uses the FreeType 1 library, and the make files + assume that the FreeType header files are in /usr/include/freetype1, and that + the freetype library is /usr/lib/libttf.so. This is how RedHat Linux 7.2 + installs FreeType 1. If your system is different, you may need to add sym + links to where the files are stored on your system, or modify + <top-src-dir>/samples/layout/Makefile.in to reference the files + correctly for your system.</p> + + <h2>How do I run the demo?</h2> + + <p>Before you can run the demo, you'll need to get the fonts it uses. For + legal reasons, we can't include these fonts with ICU, but you can download + them from the web. To do this, you'll need access to a computer running + Windows. Here's how to get the fonts:</p> + + <p>First, download the Thai font. Go to <a href= + "http://www.freelang.net/fonts/index.php">freelang.net</a> and + click on the link for the Courier Thai font. This will download a .ZIP file. + Extract the Courpro.ttf font. On Windows, copy this font file to your + Fonts folder (note the name of the font after it is installed), on Linux, copy this font file to the directory from which + you'll run the layout demo.</p> + + <p>Next is the Hindi font. Download the font from <a href= + "http://www.ffonts.net/Raghindi.font.download">Raghindi</a>. On Linux, you can download the font into the + directory from which you'll run the layout demo. On Windows, you'll need to + install it in your Fonts folder.</p> + + <p>There's still one more font to get, the Code2000 Unicode font. Go to James + Kass' <a href="http://www.code2000.net/">Unicode Support In Your + Browser</a> page and click on the link that says "Click Here to download + Code2000 shareware demo Unicode font." This will download a .ZIP file which + contains CODE2000.TTF and CODE2000.HTM. Expand this .ZIP file. If you're + going to run the layout demo on Linux, put the CODE2000.TTF file in the + directory from which you'll run the demo. On Windows, copy the font to your + fonts folder.</p> + + <p><strong>Note:</strong> The Code2000 font is shareware. If you want to use + it for longer than a trial period, you should send a shareware fee to James. + Directions for how to do this are in CODE2000.HTM.</p> + + <p>Be sure that your FontMap.GDI (on Windows) or FontMap.Gnome file (on Linux) contains accurate + font names for each script type. For example, the following is a valid FontMap.GDI (assuming you have the correct fonts): + <br><br>DEVANAGARI: Raghindi<br>THAI: Courier MonoThai<br>DEFAULT: Code2000<br><br>Note that only the Code2000 default font is strictly necessary, + and that the other two can simply be commented out by a '#' if you do not wish to use them.</p> + + <p>Also note that the FontMap and the sample.txt files have to be in the same directory as the layout executable.</p> + + <p>That's it! Now all you have to do is run letest (CTRL+F5 in Visual C++, or + "./gnomelayout" in Linux)</p> + + <h2>How can I customize the layout demo?</h2> + + <p>The text that the layout demo displays is read from the file "Sample.txt." + You can change the text by editing this file using a Unicode-aware text + editor. (it is in UTF8 format with a BOM as the first character; the demo can + also read UTF16 and UTF32 format files) Remember that the text will be + displayed in a single paragraph; you can include CR and LF characters in the + text, but they will be ignored.</p> + + <p>If you add scripts to the text other than Arabic, Devanagari, Latin or + Thai, you'll need to find a font which contains the characters in that + script, and add an entry to the FontMap file ("FontMap.GDI" on Windows, + "FontMap.Gnome" on Linux) This file contains a single entry per line. Each + entry contains a script name followed by a colon, and then a font name.</p> + + <p>Here is the list of legal script names:</p> + + <blockquote> + <tt>ARABIC</tt><br /> + <tt>ARMENIAN</tt><br /> + <tt>BENGALI</tt><br /> + <tt>BOPOMOFO</tt><br /> + <span style="font-family: monospace;">BUHID</span><br /> + <tt>CANADIAN_ABORIGINAL</tt><br /> + <tt>CHEROKEE</tt><br /> + <tt>CYRILLIC</tt><br /> + <tt>DESERET</tt><br /> + <tt>DEVANAGARI</tt><br /> + <tt>ETHIOPIC</tt><br /> + <tt>GEORGIAN</tt><br /> + <tt>GOTHIC</tt><br /> + <tt>GREEK</tt><br /> + <tt>GUJARATI</tt><br /> + <tt>GURMUKHI</tt><br /> + <tt>HAN</tt><br /> + <tt>HANGUL</tt><br /> + <span style="font-family: monospace;">HANUNOO</span><br /> + <tt>HEBREW</tt><br /> + <tt>HIRAGANA</tt><br /> + <tt>KANNADA</tt><br /> + <tt>KATAKANA</tt><br /> + <tt>KHMER</tt><br /> + <tt>LATIN</tt><br /> + <tt>MALAYALAM</tt><br /> + <tt>MONGOLIAN</tt><br /> + <tt>MYANMAR</tt><br /> + <tt>OGHAM</tt><br /> + <tt>OLD_ITALIC</tt><br /> + <tt>ORIYA</tt><br /> + <tt>RUNIC</tt><br /> + <tt>SINHALA</tt><br /> + <tt>SYRIAC</tt><br /> + <span style="font-family: monospace;">TAGALOG<br /> + TAGBANWA</span><br /> + <tt>TAMIL</tt><br /> + <tt>TELUGU</tt><br /> + <tt>THAANA</tt><br /> + <tt>THAI</tt><br /> + <tt>TIBETAN</tt><br /> + <tt>YI<br /></tt> + </blockquote> + + <p>You can also use the script name "DEFAULT" to represent all scripts which + you don't explicitly list in the FontMap file.</p> + + <p>On Windows use the full name of the font as it appears in the Windows + Fonts folder (eg. "Times New Roman") On Linux, use the file name of the font + file (e.g. "Times.TTF") If you're running on Windows, you'll need to install + the new fonts in your Fonts folder. If you're running on Linux, put them in + the directory from which you'll run the demo.</p><br /> +</body> +</html> diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/resource.h b/Build/source/libs/icu/icu-50.1/samples/layout/resource.h new file mode 100644 index 00000000000..f582d8ebbac --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/resource.h @@ -0,0 +1,22 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Copyright (c) 2001-2003 International Business Machines +// Corporation and others. All Rights Reserved. +// Used by LayoutSample.rc +// +#define IDM_FILE_NEWSAMPLE 40001 +#define IDM_FILE_OPEN 40002 +#define IDM_FILE_CLOSE 40003 +#define IDM_FILE_EXIT 40004 +#define IDM_HELP_ABOUTLAYOUTSAMPLE 40005 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40006 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/rsurface.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/rsurface.cpp new file mode 100644 index 00000000000..f383aa7dd56 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/rsurface.cpp @@ -0,0 +1,24 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include "loengine.h" +#include "rsurface.h" + +#include "LETypes.h" +#include "LEFontInstance.h" +#include "RenderingSurface.h" + +U_CDECL_BEGIN + +void rs_drawGlyphs(rs_surface *surface, const le_font *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height) +{ + RenderingSurface *rs = (RenderingSurface *) surface; + + rs->drawGlyphs((const LEFontInstance *) font, glyphs, count, positions, x, y, width, height); +} + +U_CDECL_END diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/rsurface.h b/Build/source/libs/icu/icu-50.1/samples/layout/rsurface.h new file mode 100644 index 00000000000..c58194e5f94 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/rsurface.h @@ -0,0 +1,21 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __RSURFACE_H +#define __RSURFACE_H + +#include "loengine.h" + +typedef void rs_surface; + +U_CDECL_BEGIN + +void rs_drawGlyphs(rs_surface *surface, const le_font *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height); + +U_CDECL_END + +#endif diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/sfnt.h b/Build/source/libs/icu/icu-50.1/samples/layout/sfnt.h new file mode 100644 index 00000000000..3b3d991adcc --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/sfnt.h @@ -0,0 +1,219 @@ +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2001, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + * file name: sfnt.h + * + * created on: ??/??/2001 + * created by: Eric R. Mader + */ + +#ifndef __SFNT_H +#define __SFNT_H + +#include "LETypes.h" + + +#ifndef ANY_NUMBER +#define ANY_NUMBER 1 +#endif + +struct DirectoryEntry +{ + le_uint32 tag; + le_uint32 checksum; + le_uint32 offset; + le_uint32 length; +}; + +struct SFNTDirectory +{ + le_uint32 scalerType; + le_uint16 numTables; + le_uint16 searchRange; + le_uint16 entrySelector; + le_uint16 rangeShift; + DirectoryEntry tableDirectory[ANY_NUMBER]; +}; + + +struct CMAPEncodingSubtableHeader +{ + le_uint16 platformID; + le_uint16 platformSpecificID; + le_uint32 encodingOffset; +}; + +struct CMAPTable +{ + le_uint16 version; + le_uint16 numberSubtables; + CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER]; +}; + +struct CMAPEncodingSubtable +{ + le_uint16 format; + le_uint16 length; + le_uint16 language; +}; + +struct CMAPFormat0Encoding : CMAPEncodingSubtable +{ + le_uint8 glyphIndexArray[256]; +}; + +struct CMAPFormat2Subheader +{ + le_uint16 firstCode; + le_uint16 entryCount; + le_int16 idDelta; + le_uint16 idRangeOffset; +}; + +struct CMAPFormat2Encoding : CMAPEncodingSubtable +{ + le_uint16 subHeadKeys[256]; + CMAPFormat2Subheader subheaders[ANY_NUMBER]; +}; + +struct CMAPFormat4Encoding : CMAPEncodingSubtable +{ + le_uint16 segCountX2; + le_uint16 searchRange; + le_uint16 entrySelector; + le_uint16 rangeShift; + le_uint16 endCodes[ANY_NUMBER]; +// le_uint16 reservedPad; +// le_uint16 startCodes[ANY_NUMBER]; +// le_uint16 idDelta[ANY_NUMBER]; +// le_uint16 idRangeOffset[ANY_NUMBER]; +// le_uint16 glyphIndexArray[ANY_NUMBER]; +}; + +struct CMAPFormat6Encoding : CMAPEncodingSubtable +{ + le_uint16 firstCode; + le_uint16 entryCount; + le_uint16 glyphIndexArray[ANY_NUMBER]; +}; + +struct CMAPEncodingSubtable32 +{ + le_uint32 format; + le_uint32 length; + le_uint32 language; +}; + +struct CMAPGroup +{ + le_uint32 startCharCode; + le_uint32 endCharCode; + le_uint32 startGlyphCode; +}; + +struct CMAPFormat8Encoding : CMAPEncodingSubtable32 +{ + le_uint32 is32[65536/32]; + le_uint32 nGroups; + CMAPGroup groups[ANY_NUMBER]; +}; + +struct CMAPFormat10Encoding : CMAPEncodingSubtable32 +{ + le_uint32 startCharCode; + le_uint32 numCharCodes; + le_uint16 glyphs[ANY_NUMBER]; +}; + +struct CMAPFormat12Encoding : CMAPEncodingSubtable32 +{ + le_uint32 nGroups; + CMAPGroup groups[ANY_NUMBER]; +}; + +typedef le_int32 fixed; + +struct BigDate +{ + le_uint32 bc; + le_uint32 ad; +}; + +struct HEADTable +{ + fixed version; + fixed fontRevision; + le_uint32 checksumAdjustment; + le_uint32 magicNumber; + le_uint16 flags; + le_uint16 unitsPerEm; + BigDate created; + BigDate modified; + le_int16 xMin; + le_int16 yMin; + le_int16 xMax; + le_int16 yMax; + le_int16 lowestRecPPEM; + le_int16 fontDirectionHint; + le_int16 indexToLocFormat; + le_int16 glyphDataFormat; +}; + +struct MAXPTable +{ + fixed version; + le_uint16 numGlyphs; + le_uint16 maxPoints; + le_uint16 maxContours; + le_uint16 maxComponentPoints; + le_uint16 maxComponentContours; + le_uint16 maxZones; + le_uint16 maxTwilightPoints; + le_uint16 maxStorage; + le_uint16 maxFunctionDefs; + le_uint16 maxInstructionDefs; + le_uint16 maxStackElements; + le_uint16 maxSizeOfInstructions; + le_uint16 maxComponentElements; + le_uint16 maxComponentDepth; +}; + +struct HHEATable +{ + fixed version; + le_int16 ascent; + le_int16 descent; + le_int16 lineGap; + le_uint16 advanceWidthMax; + le_int16 minLeftSideBearing; + le_int16 minRightSideBearing; + le_int16 xMaxExtent; + le_int16 caretSlopeRise; + le_int16 caretSlopeRun; + le_int16 caretOffset; + le_int16 reserved1; + le_int16 reserved2; + le_int16 reserved3; + le_int16 reserved4; + le_int16 metricDataFormat; + le_uint16 numOfLongHorMetrics; +}; + +struct LongHorMetric +{ + le_uint16 advanceWidth; + le_int16 leftSideBearing; +}; + +struct HMTXTable +{ + LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table +// le_int16 leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics +}; + +#endif + diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/ucreader.cpp b/Build/source/libs/icu/icu-50.1/samples/layout/ucreader.cpp new file mode 100644 index 00000000000..bc928417aef --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/ucreader.cpp @@ -0,0 +1,20 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include "unicode/utypes.h" + +#include "ucreader.h" +#include "gsupport.h" +#include "UnicodeReader.h" + +U_CDECL_BEGIN + +const UChar *uc_readFile(const char *fileName, gs_guiSupport *guiSupport, int32_t *charCount) +{ + return UnicodeReader::readFile(fileName, (GUISupport *) guiSupport, *charCount); +} + +U_CDECL_END diff --git a/Build/source/libs/icu/icu-50.1/samples/layout/ucreader.h b/Build/source/libs/icu/icu-50.1/samples/layout/ucreader.h new file mode 100644 index 00000000000..948db14deed --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/layout/ucreader.h @@ -0,0 +1,19 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __UCREADER_H +#define __UCREADER_H + +#include "unicode/utypes.h" +#include "gsupport.h" + +U_CDECL_BEGIN + +const UChar *uc_readFile(const char *fileName, gs_guiSupport *guiSupport, int32_t *charCount); + +U_CDECL_END + +#endif |