diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-03-19 15:59:56 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-03-19 23:38:18 +0000 |
commit | b517c251a733692f39d02f986e5010f214aea697 (patch) | |
tree | 9b60580cdd2a6441dd727a887b408058e0928022 /canvas/source | |
parent | 181feb38d95e25980b96c2f6802cc906410abb13 (diff) |
move ucs4toindex
Change-Id: I8ae441a68ba74422c607a8830325c3afa954ad92
Reviewed-on: https://gerrit.libreoffice.org/14908
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'canvas/source')
-rw-r--r-- | canvas/source/cairo/cairo_textlayout.cxx | 43 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_win32_cairo.cxx | 38 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_win32_cairo.hxx | 2 |
3 files changed, 42 insertions, 41 deletions
diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx index 9b1fa47ff0d0..936593acf760 100644 --- a/canvas/source/cairo/cairo_textlayout.cxx +++ b/canvas/source/cairo/cairo_textlayout.cxx @@ -325,6 +325,47 @@ namespace cairocanvas return true; } +#ifdef CAIRO_HAS_WIN32_SURFACE + namespace + { + /** + * cairo::ucs4toindex: Convert ucs4 char to glyph index + * @param ucs4 an ucs4 char + * @param hfont current font + * + * @return true if successful + **/ + unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont) + { + wchar_t unicode[2]; + WORD glyph_index; + HDC hdc = NULL; + + hdc = CreateCompatibleDC (NULL); + + if (!hdc) return 0; + if (!SetGraphicsMode (hdc, GM_ADVANCED)) + { + DeleteDC (hdc); + return 0; + } + + SelectObject (hdc, hfont); + SetMapMode (hdc, MM_TEXT); + + unicode[0] = ucs4; + unicode[1] = 0; + if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR) + { + glyph_index = 0; + } + + DeleteDC (hdc); + return glyph_index; + } + } +#endif + /** * TextLayout::draw * @@ -446,7 +487,7 @@ namespace cairocanvas #ifdef CAIRO_HAS_WIN32_SURFACE // Cairo requires standard glyph indexes (ETO_GLYPH_INDEX), while vcl/win/* uses ucs4 chars. // Convert to standard indexes - aGlyph.index = cairo::ucs4toindex((unsigned int) aGlyph.index, rSysFontData.hFont); + aGlyph.index = ucs4toindex((unsigned int) aGlyph.index, rSysFontData.hFont); #endif aGlyph.x = systemGlyph.x; aGlyph.y = systemGlyph.y; diff --git a/canvas/source/cairo/cairo_win32_cairo.cxx b/canvas/source/cairo/cairo_win32_cairo.cxx index a54c7e1d33d7..d6a4aba59ffd 100644 --- a/canvas/source/cairo/cairo_win32_cairo.cxx +++ b/canvas/source/cairo/cairo_win32_cairo.cxx @@ -249,44 +249,6 @@ namespace cairo return SurfaceSharedPtr(); } - - /** - * cairo::ucs4toindex: Convert ucs4 char to glyph index - * @param ucs4 an ucs4 char - * @param hfont current font - * - * @return true if successful - **/ - unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont) - { - wchar_t unicode[2]; - WORD glyph_index; - HDC hdc = NULL; - - hdc = CreateCompatibleDC (NULL); - - if (!hdc) return 0; - if (!SetGraphicsMode (hdc, GM_ADVANCED)) - { - DeleteDC (hdc); - return 0; - } - - SelectObject (hdc, hfont); - SetMapMode (hdc, MM_TEXT); - - unicode[0] = ucs4; - unicode[1] = 0; - if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR) - { - glyph_index = 0; - } - - DeleteDC (hdc); - return glyph_index; - } - - } // namespace cairo #endif // CAIRO_HAS_WIN32_SURFACE diff --git a/canvas/source/cairo/cairo_win32_cairo.hxx b/canvas/source/cairo/cairo_win32_cairo.hxx index 50bd1373e1d6..6df30f58ef40 100644 --- a/canvas/source/cairo/cairo_win32_cairo.hxx +++ b/canvas/source/cairo/cairo_win32_cairo.hxx @@ -49,8 +49,6 @@ namespace cairo { int getDepth() const; }; - - unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont); } #endif |