commit 3508d1e
chld
·
2026-07-20 15:56:46 +0000 UTC
parent 7494fd3
format and add my macdecorator
150 files changed,
+43291,
-0
+1417,
-0
1@@ -0,0 +1,1417 @@
2+/*
3+ * Copyright 2001-2014 Haiku, Inc. All rights reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * John Scipione, jscipione@gmail.com
10+ * Clemens Zeidler, haiku@clemens-zeidler.de
11+ */
12+
13+
14+/*! Decorator resembling BeOS R5 */
15+
16+
17+#include "BeDecorator.h"
18+
19+#include <algorithm>
20+#include <cmath>
21+#include <new>
22+#include <stdio.h>
23+
24+#include <WindowPrivate.h>
25+
26+#include <Autolock.h>
27+#include <Debug.h>
28+#include <GradientLinear.h>
29+#include <Rect.h>
30+#include <Region.h>
31+#include <View.h>
32+
33+#include "BitmapDrawingEngine.h"
34+#include "Desktop.h"
35+#include "DesktopSettings.h"
36+#include "DrawingEngine.h"
37+#include "DrawState.h"
38+#include "FontManager.h"
39+#include "PatternHandler.h"
40+#include "RGBColor.h"
41+#include "ServerBitmap.h"
42+
43+
44+//#define DEBUG_DECORATOR
45+#ifdef DEBUG_DECORATOR
46+# define STRACE(x) printf x
47+#else
48+# define STRACE(x) ;
49+#endif
50+
51+
52+static const float kBorderResizeLength = 22.0;
53+static const float kResizeKnobSize = 18.0;
54+
55+
56+static const unsigned char f = 0xff; // way to write 0xff shorter
57+
58+static const unsigned char kInnerShadowBits[] = {
59+ f, f, f, f, f, f, f, f, f, 0,
60+ f, f, f, f, f, f, 0, f, 0, f,
61+ f, f, f, f, f, 0, f, 0, f, 0,
62+ f, f, f, f, 0, f, 0, 0, 0, 0,
63+ f, f, f, 0, f, 0, 0, 0, 0, 0,
64+ f, f, 0, f, 0, 0, 0, 0, 0, 0,
65+ f, 0, f, 0, 0, 0, 0, 0, 0, 0,
66+ f, f, 0, 0, 0, 0, 0, 0, 0, 0,
67+ f, 0, f, 0, 0, 0, 0, 0, 0, 0,
68+ 0, f, 0, 0, 0, 0, 0, 0, 0, 0
69+};
70+
71+static const unsigned char kOuterShadowBits[] = {
72+ f, f, f, f, f, f, f, f, f, f,
73+ f, f, f, f, f, f, f, f, f, f,
74+ f, f, f, f, f, f, f, f, f, f,
75+ f, f, f, f, f, f, f, f, f, f,
76+ f, f, f, f, f, f, f, f, f, 0,
77+ f, f, f, f, f, f, f, 0, 0, 0,
78+ f, f, f, f, f, f, 0, f, 0, 0,
79+ f, f, f, f, f, 0, f, 0, 0, 0,
80+ f, f, f, f, f, 0, 0, 0, 0, 0,
81+ f, f, f, f, 0, 0, 0, 0, 0, 0
82+};
83+
84+static const unsigned char kBigInnerShadowBits[] = {
85+ f, f, f, f, f, f, f,
86+ f, f, f, f, f, f, 0,
87+ f, f, f, f, f, 0, 0,
88+ f, f, f, f, 0, f, 0,
89+ f, f, f, 0, f, 0, 0,
90+ f, f, 0, f, 0, 0, 0,
91+ f, 0, 0, 0, 0, 0, 0
92+};
93+
94+static const unsigned char kBigOuterShadowBits[] = {
95+ f, f, f, f, f, f, f,
96+ f, f, f, f, f, f, 0,
97+ f, f, f, f, f, f, 0,
98+ f, f, f, f, f, f, 0,
99+ f, f, f, f, f, f, 0,
100+ f, f, f, f, f, f, 0,
101+ f, 0, 0, 0, 0, 0, 0
102+};
103+
104+static const unsigned char kSmallInnerShadowBits[] = {
105+ f, f, f, 0, 0,
106+ f, f, 0, f, 0,
107+ f, 0, f, 0, 0,
108+ 0, f, 0, 0, 0,
109+ 0, 0, 0, 0, 0
110+};
111+
112+static const unsigned char kSmallOuterShadowBits[] = {
113+ f, f, f, f, f,
114+ f, f, f, f, f,
115+ f, f, f, f, f,
116+ f, f, f, f, 0,
117+ f, f, 0, 0, 0
118+};
119+
120+static const unsigned char kGlintBits[] = {
121+ 0, f, 0,
122+ f, 0, f,
123+ 0, f, f
124+};
125+
126+
127+// #pragma mark - BeDecorAddOn
128+
129+
130+BeDecorAddOn::BeDecorAddOn(image_id id, const char* name)
131+ :
132+ DecorAddOn(id, name)
133+{
134+}
135+
136+
137+Decorator*
138+BeDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect,
139+ Desktop* desktop)
140+{
141+ return new (std::nothrow)BeDecorator(settings, rect, desktop);
142+}
143+
144+
145+// #pragma mark - BeDecorator
146+
147+
148+// TODO: get rid of DesktopSettings here, and introduce private accessor
149+// methods to the Decorator base class
150+BeDecorator::BeDecorator(DesktopSettings& settings, BRect rect,
151+ Desktop* desktop)
152+ :
153+ SATDecorator(settings, rect, desktop),
154+ fCStatus(B_NO_INIT)
155+{
156+ STRACE(("BeDecorator:\n"));
157+ STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
158+ rect.left, rect.top, rect.right, rect.bottom));
159+
160+ fCloseBitmap = _CreateTemporaryBitmap(BRect(0, 0, 9, 9));
161+ fBigZoomBitmap = _CreateTemporaryBitmap(BRect(0, 0, 6, 6));
162+ fSmallZoomBitmap = _CreateTemporaryBitmap(BRect(0, 0, 4, 4));
163+ fGlintBitmap = _CreateTemporaryBitmap(BRect(0, 0, 2, 2));
164+ // glint bitmap is used by close and zoom buttons
165+
166+ if (fCloseBitmap == NULL || fBigZoomBitmap == NULL
167+ || fSmallZoomBitmap == NULL || fGlintBitmap == NULL) {
168+ fCStatus = B_NO_MEMORY;
169+ } else
170+ fCStatus = B_OK;
171+}
172+
173+
174+BeDecorator::~BeDecorator()
175+{
176+ STRACE(("BeDecorator: ~BeDecorator()\n"));
177+ //delete[] fFrameColors;
178+
179+ if (fCloseBitmap != NULL)
180+ fCloseBitmap->ReleaseReference();
181+
182+ if (fBigZoomBitmap != NULL)
183+ fBigZoomBitmap->ReleaseReference();
184+
185+ if (fSmallZoomBitmap != NULL)
186+ fSmallZoomBitmap->ReleaseReference();
187+
188+ if (fGlintBitmap != NULL)
189+ fGlintBitmap->ReleaseReference();
190+}
191+
192+
193+// #pragma mark - Public methods
194+
195+
196+/*! Returns the frame colors for the specified decorator component.
197+
198+ The meaning of the color array elements depends on the specified component.
199+ For some components some array elements are unused.
200+
201+ \param component The component for which to return the frame colors.
202+ \param highlight The highlight set for the component.
203+ \param colors An array of colors to be initialized by the function.
204+*/
205+void
206+BeDecorator::GetComponentColors(Component component, uint8 highlight,
207+ ComponentColors _colors, Decorator::Tab* _tab)
208+{
209+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
210+ switch (component) {
211+ case COMPONENT_TAB:
212+ if (highlight == HIGHLIGHT_STACK_AND_TILE) {
213+ _colors[COLOR_TAB_FRAME_LIGHT]
214+ = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
215+ _colors[COLOR_TAB_FRAME_DARK]
216+ = tint_color(fFocusFrameColor, B_DARKEN_4_TINT);
217+ _colors[COLOR_TAB] = tint_color(fFocusTabColor,
218+ B_DARKEN_1_TINT);
219+ _colors[COLOR_TAB_LIGHT] = tint_color(fFocusTabColorLight,
220+ B_DARKEN_1_TINT);
221+ _colors[COLOR_TAB_BEVEL] = fFocusTabColorBevel;
222+ _colors[COLOR_TAB_SHADOW] = fFocusTabColorShadow;
223+ _colors[COLOR_TAB_TEXT] = fFocusTextColor;
224+ } else if (tab && tab->buttonFocus) {
225+ _colors[COLOR_TAB_FRAME_LIGHT]
226+ = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
227+ _colors[COLOR_TAB_FRAME_DARK]
228+ = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
229+ _colors[COLOR_TAB] = fFocusTabColor;
230+ _colors[COLOR_TAB_LIGHT] = fFocusTabColorLight;
231+ _colors[COLOR_TAB_BEVEL] = fFocusTabColorBevel;
232+ _colors[COLOR_TAB_SHADOW] = fFocusTabColorShadow;
233+ _colors[COLOR_TAB_TEXT] = fFocusTextColor;
234+ } else {
235+ _colors[COLOR_TAB_FRAME_LIGHT]
236+ = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
237+ _colors[COLOR_TAB_FRAME_DARK]
238+ = tint_color(fNonFocusFrameColor, B_DARKEN_3_TINT);
239+ _colors[COLOR_TAB] = fNonFocusTabColor;
240+ _colors[COLOR_TAB_LIGHT] = fNonFocusTabColorLight;
241+ _colors[COLOR_TAB_BEVEL] = fNonFocusTabColorBevel;
242+ _colors[COLOR_TAB_SHADOW] = fNonFocusTabColorShadow;
243+ _colors[COLOR_TAB_TEXT] = fNonFocusTextColor;
244+ }
245+ break;
246+
247+ case COMPONENT_CLOSE_BUTTON:
248+ case COMPONENT_ZOOM_BUTTON:
249+ if (highlight == HIGHLIGHT_STACK_AND_TILE) {
250+ _colors[COLOR_BUTTON] = tint_color(fFocusTabColor,
251+ B_DARKEN_1_TINT);
252+ _colors[COLOR_BUTTON_LIGHT] = tint_color(fFocusTabColorLight,
253+ B_DARKEN_1_TINT);
254+ } else if (tab && tab->buttonFocus) {
255+ _colors[COLOR_BUTTON] = fFocusTabColor;
256+ _colors[COLOR_BUTTON_LIGHT] = fFocusTabColorLight;
257+ } else {
258+ _colors[COLOR_BUTTON] = fNonFocusTabColor;
259+ _colors[COLOR_BUTTON_LIGHT] = fNonFocusTabColorLight;
260+ }
261+ break;
262+
263+ case COMPONENT_LEFT_BORDER:
264+ case COMPONENT_RIGHT_BORDER:
265+ case COMPONENT_TOP_BORDER:
266+ case COMPONENT_BOTTOM_BORDER:
267+ case COMPONENT_RESIZE_CORNER:
268+ default:
269+ {
270+ rgb_color base;
271+ if (highlight == HIGHLIGHT_STACK_AND_TILE)
272+ base = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
273+ else if (tab && tab->buttonFocus)
274+ base = fFocusFrameColor;
275+ else
276+ base = fNonFocusFrameColor;
277+
278+ //_colors[0].SetColor(152, 152, 152);
279+ //_colors[1].SetColor(255, 255, 255);
280+ //_colors[2].SetColor(216, 216, 216);
281+ //_colors[3].SetColor(136, 136, 136);
282+ //_colors[4].SetColor(152, 152, 152);
283+ //_colors[5].SetColor(96, 96, 96);
284+
285+ _colors[0].red = std::max(0, base.red - 72);
286+ _colors[0].green = std::max(0, base.green - 72);
287+ _colors[0].blue = std::max(0, base.blue - 72);
288+ _colors[0].alpha = 255;
289+
290+ _colors[1].red = std::min(255, base.red + 64);
291+ _colors[1].green = std::min(255, base.green + 64);
292+ _colors[1].blue = std::min(255, base.blue + 64);
293+ _colors[1].alpha = 255;
294+
295+ _colors[2].red = std::max(0, base.red - 8);
296+ _colors[2].green = std::max(0, base.green - 8);
297+ _colors[2].blue = std::max(0, base.blue - 8);
298+ _colors[2].alpha = 255;
299+
300+ _colors[3].red = std::max(0, base.red - 88);
301+ _colors[3].green = std::max(0, base.green - 88);
302+ _colors[3].blue = std::max(0, base.blue - 88);
303+ _colors[3].alpha = 255;
304+
305+ _colors[4].red = std::max(0, base.red - 72);
306+ _colors[4].green = std::max(0, base.green - 72);
307+ _colors[4].blue = std::max(0, base.blue - 72);
308+ _colors[4].alpha = 255;
309+
310+ _colors[5].red = std::max(0, base.red - 128);
311+ _colors[5].green = std::max(0, base.green - 128);
312+ _colors[5].blue = std::max(0, base.blue - 128);
313+ _colors[5].alpha = 255;
314+
315+ // for the resize-border highlight dye everything bluish.
316+ if (highlight == HIGHLIGHT_RESIZE_BORDER) {
317+ for (int32 i = 0; i < 6; i++) {
318+ _colors[i].red = std::max((int)_colors[i].red - 80, 0);
319+ _colors[i].green = std::max((int)_colors[i].green - 80, 0);
320+ _colors[i].blue = 255;
321+ }
322+ }
323+ break;
324+ }
325+ }
326+}
327+
328+
329+// #pragma mark - Protected methods
330+
331+
332+void
333+BeDecorator::_DrawFrame(BRect invalid)
334+{
335+ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
336+ invalid.right, invalid.bottom));
337+
338+ // NOTE: the DrawingEngine needs to be locked for the entire
339+ // time for the clipping to stay valid for this decorator
340+
341+ if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
342+ return;
343+
344+ if (fBorderWidth <= 0)
345+ return;
346+
347+ // Draw the border frame
348+ BRect r = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
349+ switch ((int)fTopTab->look) {
350+ case B_TITLED_WINDOW_LOOK:
351+ case B_DOCUMENT_WINDOW_LOOK:
352+ case B_MODAL_WINDOW_LOOK:
353+ {
354+ // top
355+ if (invalid.Intersects(fTopBorder)) {
356+ ComponentColors colors;
357+ _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
358+
359+ for (int8 i = 0; i < 5; i++) {
360+ fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
361+ BPoint(r.right - i, r.top + i), colors[i]);
362+ }
363+ if (fTitleBarRect.IsValid()) {
364+ // grey along the bottom of the tab
365+ // (overwrites "white" from frame)
366+ fDrawingEngine->StrokeLine(
367+ BPoint(fTitleBarRect.left + 2,
368+ fTitleBarRect.bottom + 1),
369+ BPoint(fTitleBarRect.right - 2,
370+ fTitleBarRect.bottom + 1),
371+ colors[2]);
372+ }
373+ }
374+ // left
375+ if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
376+ ComponentColors colors;
377+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
378+
379+ for (int8 i = 0; i < 5; i++) {
380+ fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
381+ BPoint(r.left + i, r.bottom - i), colors[i]);
382+ }
383+ }
384+ // bottom
385+ if (invalid.Intersects(fBottomBorder)) {
386+ ComponentColors colors;
387+ _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
388+
389+ for (int8 i = 0; i < 5; i++) {
390+ fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
391+ BPoint(r.right - i, r.bottom - i),
392+ colors[(4 - i) == 4 ? 5 : (4 - i)]);
393+ }
394+ }
395+ // right
396+ if (invalid.Intersects(
397+ fRightBorder.InsetByCopy(0, -fBorderWidth))) {
398+ ComponentColors colors;
399+ _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
400+
401+ for (int8 i = 0; i < 5; i++) {
402+ fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
403+ BPoint(r.right - i, r.bottom - i),
404+ colors[(4 - i) == 4 ? 5 : (4 - i)]);
405+ }
406+ }
407+ break;
408+ }
409+
410+ case B_FLOATING_WINDOW_LOOK:
411+ case kLeftTitledWindowLook:
412+ {
413+ // top
414+ if (invalid.Intersects(fTopBorder)) {
415+ ComponentColors colors;
416+ _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
417+
418+ for (int8 i = 0; i < 3; i++) {
419+ fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
420+ BPoint(r.right - i, r.top + i), colors[i * 2]);
421+ }
422+ if (fTitleBarRect.IsValid()
423+ && fTopTab->look != kLeftTitledWindowLook) {
424+ // grey along the bottom of the tab
425+ // (overwrites "white" from frame)
426+ fDrawingEngine->StrokeLine(
427+ BPoint(fTitleBarRect.left + 2,
428+ fTitleBarRect.bottom + 1),
429+ BPoint(fTitleBarRect.right - 2,
430+ fTitleBarRect.bottom + 1), colors[2]);
431+ }
432+ }
433+ // left
434+ if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
435+ ComponentColors colors;
436+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
437+
438+ for (int8 i = 0; i < 3; i++) {
439+ fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
440+ BPoint(r.left + i, r.bottom - i), colors[i * 2]);
441+ }
442+ if (fTopTab->look == kLeftTitledWindowLook
443+ && fTitleBarRect.IsValid()) {
444+ // grey along the right side of the tab
445+ // (overwrites "white" from frame)
446+ fDrawingEngine->StrokeLine(
447+ BPoint(fTitleBarRect.right + 1,
448+ fTitleBarRect.top + 2),
449+ BPoint(fTitleBarRect.right + 1,
450+ fTitleBarRect.bottom - 2), colors[2]);
451+ }
452+ }
453+ // bottom
454+ if (invalid.Intersects(fBottomBorder)) {
455+ ComponentColors colors;
456+ _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
457+
458+ for (int8 i = 0; i < 3; i++) {
459+ fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
460+ BPoint(r.right - i, r.bottom - i),
461+ colors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
462+ }
463+ }
464+ // right
465+ if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
466+ ComponentColors colors;
467+ _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
468+
469+ for (int8 i = 0; i < 3; i++) {
470+ fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
471+ BPoint(r.right - i, r.bottom - i),
472+ colors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
473+ }
474+ }
475+ break;
476+ }
477+
478+ case B_BORDERED_WINDOW_LOOK:
479+ {
480+ // TODO: Draw the borders individually!
481+ ComponentColors colors;
482+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
483+
484+ fDrawingEngine->StrokeRect(r, colors[5]);
485+ break;
486+ }
487+
488+ default:
489+ // don't draw a border frame
490+ break;
491+ }
492+
493+ // Draw the resize knob if we're supposed to
494+ if (!(fTopTab->flags & B_NOT_RESIZABLE)) {
495+ r = fResizeRect;
496+
497+ ComponentColors colors;
498+ _GetComponentColors(COMPONENT_RESIZE_CORNER, colors, fTopTab);
499+
500+ switch ((int)fTopTab->look) {
501+ case B_DOCUMENT_WINDOW_LOOK:
502+ {
503+ if (!invalid.Intersects(r))
504+ break;
505+
506+ float x = r.right - 3;
507+ float y = r.bottom - 3;
508+
509+ BRect bg(x - 13, y - 13, x, y);
510+
511+ BGradientLinear gradient;
512+ gradient.SetStart(bg.LeftTop());
513+ gradient.SetEnd(bg.RightBottom());
514+ gradient.AddColor(colors[1], 0);
515+ gradient.AddColor(colors[2], 255);
516+
517+ fDrawingEngine->FillRect(bg, gradient);
518+
519+ fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15),
520+ BPoint(x - 15, y - 2), colors[0]);
521+ fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14),
522+ BPoint(x - 14, y - 1), colors[1]);
523+ fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15),
524+ BPoint(x - 2, y - 15), colors[0]);
525+ fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14),
526+ BPoint(x - 1, y - 14), colors[1]);
527+
528+ if (fTopTab && !IsFocus(fTopTab))
529+ break;
530+
531+ static const rgb_color kWhite
532+ = (rgb_color){ 255, 255, 255, 255 };
533+ for (int8 i = 1; i <= 4; i++) {
534+ for (int8 j = 1; j <= i; j++) {
535+ BPoint pt1(x - (3 * j) + 1, y - (3 * (5 - i)) + 1);
536+ BPoint pt2(x - (3 * j) + 2, y - (3 * (5 - i)) + 2);
537+ fDrawingEngine->StrokePoint(pt1, colors[0]);
538+ fDrawingEngine->StrokePoint(pt2, kWhite);
539+ }
540+ }
541+ break;
542+ }
543+
544+ case B_TITLED_WINDOW_LOOK:
545+ case B_FLOATING_WINDOW_LOOK:
546+ case B_MODAL_WINDOW_LOOK:
547+ case kLeftTitledWindowLook:
548+ {
549+ if (!invalid.Intersects(BRect(fRightBorder.right
550+ - kBorderResizeLength,
551+ fBottomBorder.bottom - kBorderResizeLength,
552+ fRightBorder.right - 1, fBottomBorder.bottom - 1))) {
553+ break;
554+ }
555+
556+ fDrawingEngine->StrokeLine(BPoint(fRightBorder.left,
557+ fBottomBorder.bottom - kBorderResizeLength),
558+ BPoint(fRightBorder.right - 1,
559+ fBottomBorder.bottom - kBorderResizeLength),
560+ colors[0]);
561+ fDrawingEngine->StrokeLine(
562+ BPoint(fRightBorder.right - kBorderResizeLength,
563+ fBottomBorder.top),
564+ BPoint(fRightBorder.right - kBorderResizeLength,
565+ fBottomBorder.bottom - 1),
566+ colors[0]);
567+ break;
568+ }
569+
570+ default:
571+ // don't draw resize corner
572+ break;
573+ }
574+ }
575+}
576+
577+
578+/*! \brief Actually draws the tab
579+
580+ This function is called when the tab itself needs drawn. Other items,
581+ like the window title or buttons, should not be drawn here.
582+
583+ \param tab The \a tab to update.
584+ \param invalid The area of the \a tab to update.
585+*/
586+void
587+BeDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
588+{
589+ STRACE(("_DrawTab(%.1f, %.1f, %.1f, %.1f)\n",
590+ invalid.left, invalid.top, invalid.right, invalid.bottom));
591+ const BRect& tabRect = tab->tabRect;
592+ // If a window has a tab, this will draw it and any buttons which are
593+ // in it.
594+ if (!tabRect.IsValid() || !invalid.Intersects(tabRect))
595+ return;
596+
597+ ComponentColors colors;
598+ _GetComponentColors(COMPONENT_TAB, colors, tab);
599+
600+ // outer frame
601+ fDrawingEngine->StrokeLine(tabRect.LeftTop(), tabRect.LeftBottom(),
602+ colors[COLOR_TAB_FRAME_LIGHT]);
603+ fDrawingEngine->StrokeLine(tabRect.LeftTop(), tabRect.RightTop(),
604+ colors[COLOR_TAB_FRAME_LIGHT]);
605+ if (tab->look != kLeftTitledWindowLook) {
606+ fDrawingEngine->StrokeLine(tabRect.RightTop(), tabRect.RightBottom(),
607+ colors[COLOR_TAB_FRAME_DARK]);
608+ } else {
609+ fDrawingEngine->StrokeLine(tabRect.LeftBottom(),
610+ tabRect.RightBottom(), colors[COLOR_TAB_FRAME_DARK]);
611+ }
612+
613+ float tabBotton = tabRect.bottom;
614+ if (fTopTab != tab)
615+ tabBotton -= 1;
616+
617+ // bevel
618+ fDrawingEngine->StrokeLine(BPoint(tabRect.left + 1, tabRect.top + 1),
619+ BPoint(tabRect.left + 1,
620+ tabBotton - (tab->look == kLeftTitledWindowLook ? 1 : 0)),
621+ colors[COLOR_TAB_BEVEL]);
622+ fDrawingEngine->StrokeLine(BPoint(tabRect.left + 1, tabRect.top + 1),
623+ BPoint(tabRect.right - (tab->look == kLeftTitledWindowLook ? 0 : 1),
624+ tabRect.top + 1),
625+ colors[COLOR_TAB_BEVEL]);
626+
627+ if (tab->look != kLeftTitledWindowLook) {
628+ fDrawingEngine->StrokeLine(BPoint(tabRect.right - 1, tabRect.top + 2),
629+ BPoint(tabRect.right - 1, tabBotton),
630+ colors[COLOR_TAB_SHADOW]);
631+ } else {
632+ fDrawingEngine->StrokeLine(
633+ BPoint(tabRect.left + 2, tabRect.bottom - 1),
634+ BPoint(tabRect.right, tabRect.bottom - 1),
635+ colors[COLOR_TAB_SHADOW]);
636+ }
637+
638+ // fill
639+ if (fTopTab->look != kLeftTitledWindowLook) {
640+ fDrawingEngine->FillRect(BRect(tabRect.left + 2, tabRect.top + 2,
641+ tabRect.right - 2, tabRect.bottom), colors[COLOR_TAB]);
642+ } else {
643+ fDrawingEngine->FillRect(BRect(tabRect.left + 2, tabRect.top + 2,
644+ tabRect.right, tabRect.bottom - 2), colors[COLOR_TAB]);
645+ }
646+
647+ _DrawTitle(tab, tabRect);
648+
649+ _DrawButtons(tab, invalid);
650+}
651+
652+
653+/*! \brief Actually draws the title
654+
655+ The main tasks for this function are to ensure that the decorator draws
656+ the title only in its own area and drawing the title itself.
657+ Using B_OP_COPY for drawing the title is recommended because of the marked
658+ performance hit of the other drawing modes, but it is not a requirement.
659+
660+ \param _tab The \a tab to update.
661+ \param r area of the title to update.
662+*/
663+void
664+BeDecorator::_DrawTitle(Decorator::Tab* _tab, BRect r)
665+{
666+ STRACE(("_DrawTitle(%f, %f, %f, %f)\n", r.left, r.top, r.right, r.bottom));
667+
668+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
669+
670+ const BRect& tabRect = tab->tabRect;
671+ const BRect& closeRect = tab->closeRect;
672+ const BRect& zoomRect = tab->zoomRect;
673+
674+ ComponentColors colors;
675+ _GetComponentColors(COMPONENT_TAB, colors, tab);
676+
677+ fDrawingEngine->SetDrawingMode(B_OP_OVER);
678+ fDrawingEngine->SetHighColor(colors[COLOR_TAB_TEXT]);
679+ fDrawingEngine->SetLowColor(colors[COLOR_TAB]);
680+ fDrawingEngine->SetFont(fDrawState.Font());
681+
682+ // figure out position of text
683+ font_height fontHeight;
684+ fDrawState.Font().GetHeight(fontHeight);
685+
686+ BPoint titlePos;
687+ if (fTopTab->look != kLeftTitledWindowLook) {
688+ titlePos.x = closeRect.IsValid() ? closeRect.right + tab->textOffset
689+ : tabRect.left + tab->textOffset;
690+ titlePos.y = floorf(((tabRect.top + 2.0) + tabRect.bottom
691+ + fontHeight.ascent + fontHeight.descent) / 2.0
692+ - fontHeight.descent + 0.5);
693+ } else {
694+ titlePos.x = floorf(((tabRect.left + 2.0) + tabRect.right
695+ + fontHeight.ascent + fontHeight.descent) / 2.0
696+ - fontHeight.descent + 0.5);
697+ titlePos.y = zoomRect.IsValid() ? zoomRect.top - tab->textOffset
698+ : tabRect.bottom - tab->textOffset;
699+ }
700+
701+ fDrawingEngine->SetFont(fDrawState.Font());
702+
703+ fDrawingEngine->DrawString(tab->truncatedTitle.String(),
704+ tab->truncatedTitleLength, titlePos);
705+
706+ fDrawingEngine->SetDrawingMode(B_OP_COPY);
707+}
708+
709+
710+/*! \brief Actually draws the close button
711+
712+ Unless a subclass has a particularly large button, it is probably
713+ unnecessary to check the update rectangle.
714+
715+ \param _tab The \a tab to update.
716+ \param direct Draw without double buffering.
717+ \param rect The area of the button to update.
718+*/
719+void
720+BeDecorator::_DrawClose(Decorator::Tab* _tab, bool direct, BRect rect)
721+{
722+ STRACE(("_DrawClose(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
723+ rect.bottom));
724+
725+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
726+
727+ int32 index = (tab->buttonFocus ? 0 : 1) + (tab->closePressed ? 0 : 2);
728+ ServerBitmap* bitmap = tab->closeBitmaps[index];
729+ if (bitmap == NULL) {
730+ bitmap = _GetBitmapForButton(tab, COMPONENT_CLOSE_BUTTON,
731+ tab->closePressed, rect.IntegerWidth(), rect.IntegerHeight());
732+ tab->closeBitmaps[index] = bitmap;
733+ }
734+
735+ _DrawButtonBitmap(bitmap, direct, rect);
736+}
737+
738+
739+/*! \brief Actually draws the zoom button
740+
741+ Unless a subclass has a particularly large button, it is probably
742+ unnecessary to check the update rectangle.
743+
744+ \param _tab The \a tab to update.
745+ \param direct Draw without double buffering.
746+ \param rect The area of the button to update.
747+*/
748+void
749+BeDecorator::_DrawZoom(Decorator::Tab* _tab, bool direct, BRect rect)
750+{
751+ STRACE(("_DrawZoom(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
752+ rect.bottom));
753+
754+ if (rect.IntegerWidth() < 1)
755+ return;
756+
757+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
758+ int32 index = (tab->buttonFocus ? 0 : 1) + (tab->zoomPressed ? 0 : 2);
759+ ServerBitmap* bitmap = tab->zoomBitmaps[index];
760+ if (bitmap == NULL) {
761+ bitmap = _GetBitmapForButton(tab, COMPONENT_ZOOM_BUTTON,
762+ tab->zoomPressed, rect.IntegerWidth(), rect.IntegerHeight());
763+ tab->zoomBitmaps[index] = bitmap;
764+ }
765+
766+ _DrawButtonBitmap(bitmap, direct, rect);
767+}
768+
769+
770+void
771+BeDecorator::_DrawMinimize(Decorator::Tab* tab, bool direct, BRect rect)
772+{
773+ // This decorator doesn't have this button
774+}
775+
776+
777+void
778+BeDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset,
779+ float* _size, float* _inset) const
780+{
781+ float tabSize = fTopTab->look == kLeftTitledWindowLook ?
782+ tabRect.Width() : tabRect.Height();
783+
784+ *_offset = 5.0f;
785+ *_inset = 0.0f;
786+
787+ *_size = std::max(0.0f, tabSize - 7.0f);
788+}
789+
790+
791+// #pragma mark - Private methods
792+
793+
794+/*!
795+ \brief Draws a bevel around a rectangle.
796+ \param rect The rectangular area to draw in.
797+ \param down Whether or not the button is pressed down.
798+ \param light The light color to use.
799+ \param shadow The shadow color to use.
800+*/
801+void
802+BeDecorator::_DrawBevelRect(DrawingEngine* engine, const BRect rect, bool down,
803+ rgb_color light, rgb_color shadow)
804+{
805+ if (down) {
806+ BRect inner(rect.InsetByCopy(1.0f, 1.0f));
807+
808+ engine->StrokeLine(rect.LeftBottom(), rect.LeftTop(), shadow);
809+ engine->StrokeLine(rect.LeftTop(), rect.RightTop(), shadow);
810+ engine->StrokeLine(inner.LeftBottom(), inner.LeftTop(), shadow);
811+ engine->StrokeLine(inner.LeftTop(), inner.RightTop(), shadow);
812+
813+ engine->StrokeLine(rect.RightTop(), rect.RightBottom(), light);
814+ engine->StrokeLine(rect.RightBottom(), rect.LeftBottom(), light);
815+ engine->StrokeLine(inner.RightTop(), inner.RightBottom(), light);
816+ engine->StrokeLine(inner.RightBottom(), inner.LeftBottom(), light);
817+ } else {
818+ BRect r1(rect);
819+ r1.left += 1.0f;
820+ r1.top += 1.0f;
821+
822+ BRect r2(rect);
823+ r2.bottom -= 1.0f;
824+ r2.right -= 1.0f;
825+
826+ engine->StrokeRect(r2, shadow);
827+ // inner dark box
828+ engine->StrokeRect(rect, shadow);
829+ // outer dark box
830+ engine->StrokeRect(r1, light);
831+ // light box
832+ }
833+}
834+
835+
836+/*!
837+ \brief Draws a framed rectangle with a gradient.
838+ \param rect The rectangular area to draw in.
839+ \param startColor The start color of the gradient.
840+ \param endColor The end color of the gradient.
841+*/
842+void
843+BeDecorator::_DrawBlendedRect(DrawingEngine* engine, const BRect rect,
844+ bool down, rgb_color colorA, rgb_color colorB, rgb_color colorC,
845+ rgb_color colorD)
846+{
847+ BRect fillRect(rect.InsetByCopy(1.0f, 1.0f));
848+
849+ BGradientLinear gradient;
850+ if (down) {
851+ gradient.SetStart(fillRect.RightBottom());
852+ gradient.SetEnd(fillRect.LeftTop());
853+ } else {
854+ gradient.SetStart(fillRect.LeftTop());
855+ gradient.SetEnd(fillRect.RightBottom());
856+ }
857+
858+ gradient.AddColor(colorA, 0);
859+ gradient.AddColor(colorB, 95);
860+ gradient.AddColor(colorC, 159);
861+ gradient.AddColor(colorD, 255);
862+
863+ engine->FillRect(fillRect, gradient);
864+}
865+
866+
867+void
868+BeDecorator::_DrawButtonBitmap(ServerBitmap* bitmap, bool direct, BRect rect)
869+{
870+ if (bitmap == NULL)
871+ return;
872+
873+ bool copyToFrontEnabled = fDrawingEngine->CopyToFrontEnabled();
874+ fDrawingEngine->SetCopyToFrontEnabled(direct);
875+ drawing_mode oldMode;
876+ fDrawingEngine->SetDrawingMode(B_OP_OVER, oldMode);
877+ fDrawingEngine->DrawBitmap(bitmap, rect.OffsetToCopy(0, 0), rect);
878+ fDrawingEngine->SetDrawingMode(oldMode);
879+ fDrawingEngine->SetCopyToFrontEnabled(copyToFrontEnabled);
880+}
881+
882+
883+ServerBitmap*
884+BeDecorator::_GetBitmapForButton(Decorator::Tab* tab, Component item,
885+ bool down, int32 width, int32 height)
886+{
887+ uint8* data;
888+ size_t size;
889+ size_t offset;
890+
891+ // TODO: the list of shared bitmaps is never freed
892+ struct decorator_bitmap {
893+ Component item;
894+ bool down;
895+ int32 width;
896+ int32 height;
897+ rgb_color baseColor;
898+ rgb_color lightColor;
899+ UtilityBitmap* bitmap;
900+ decorator_bitmap* next;
901+ };
902+
903+ static BLocker sBitmapListLock("decorator lock", true);
904+ static decorator_bitmap* sBitmapList = NULL;
905+
906+ // BeOS R5 colors
907+ // button: active: 255, 203, 0 inactive: 232, 232, 232
908+ // light1: active: 255, 238, 0 inactive: 255, 255, 255
909+ // light2: active: 255, 255, 26 inactive: 255, 255, 255
910+ // shadow1: active: 235, 183, 0 inactive: 211, 211, 211
911+ // shadow2 is a bit lighter on zoom than on close button
912+
913+ ComponentColors colors;
914+ _GetComponentColors(item, colors, tab);
915+
916+ const rgb_color buttonColor(colors[COLOR_BUTTON]);
917+
918+ bool isGrayscale = buttonColor.red == buttonColor.green
919+ && buttonColor.green == buttonColor.blue;
920+
921+ rgb_color buttonColorLight1(buttonColor);
922+ buttonColorLight1.red = std::min(255, buttonColor.red + 35),
923+ buttonColorLight1.green = std::min(255, buttonColor.green + 35),
924+ buttonColorLight1.blue = std::min(255, buttonColor.blue
925+ + (isGrayscale ? 35 : 0));
926+ // greyscale color stays grayscale
927+
928+ rgb_color buttonColorLight2(buttonColor);
929+ buttonColorLight2.red = std::min(255, buttonColor.red + 52),
930+ buttonColorLight2.green = std::min(255, buttonColor.green + 52),
931+ buttonColorLight2.blue = std::min(255, buttonColor.blue + 26);
932+
933+ rgb_color buttonColorShadow1(buttonColor);
934+ buttonColorShadow1.red = std::max(0, buttonColor.red - 21),
935+ buttonColorShadow1.green = std::max(0, buttonColor.green - 21),
936+ buttonColorShadow1.blue = std::max(0, buttonColor.blue - 21);
937+
938+ BAutolock locker(sBitmapListLock);
939+
940+ // search our list for a matching bitmap
941+ // TODO: use a hash map instead?
942+ decorator_bitmap* current = sBitmapList;
943+ while (current) {
944+ if (current->item == item && current->down == down
945+ && current->width == width && current->height == height
946+ && current->baseColor == colors[COLOR_BUTTON]
947+ && current->lightColor == colors[COLOR_BUTTON_LIGHT]) {
948+ return current->bitmap;
949+ }
950+
951+ current = current->next;
952+ }
953+
954+ static BitmapDrawingEngine* sBitmapDrawingEngine = NULL;
955+
956+ // didn't find any bitmap, create a new one
957+ if (sBitmapDrawingEngine == NULL)
958+ sBitmapDrawingEngine = new(std::nothrow) BitmapDrawingEngine();
959+ if (sBitmapDrawingEngine == NULL
960+ || sBitmapDrawingEngine->SetSize(width, height) != B_OK) {
961+ return NULL;
962+ }
963+
964+ BRect rect(0, 0, width - 1, height - 1);
965+
966+ STRACE(("BeDecorator creating bitmap for %s %s at size %ldx%ld\n",
967+ item == COMPONENT_CLOSE_BUTTON ? "close" : "zoom",
968+ down ? "down" : "up", width, height));
969+ switch (item) {
970+ case COMPONENT_CLOSE_BUTTON:
971+ {
972+ // BeOS R5 shadow2: active: 183, 131, 0 inactive: 160, 160, 160
973+ rgb_color buttonColorShadow2(buttonColor);
974+ buttonColorShadow2.red = std::max(0, buttonColor.red - 72),
975+ buttonColorShadow2.green = std::max(0, buttonColor.green - 72),
976+ buttonColorShadow2.blue = std::max(0, buttonColor.blue - 72);
977+
978+ // fill the background
979+ sBitmapDrawingEngine->FillRect(rect, buttonColor);
980+
981+ // draw outer bevel
982+ _DrawBevelRect(sBitmapDrawingEngine, rect, tab->closePressed,
983+ buttonColorLight2, buttonColorShadow2);
984+
985+ if (fCStatus != B_OK) {
986+ // If we ran out of memory while initializing bitmaps
987+ // fall back to a linear gradient.
988+ rect.InsetBy(1, 1);
989+ _DrawBlendedRect(sBitmapDrawingEngine, rect, tab->closePressed,
990+ buttonColorLight2, buttonColorLight1, buttonColor,
991+ buttonColorShadow1);
992+
993+ break;
994+ }
995+
996+ // inset by bevel
997+ rect.InsetBy(2, 2);
998+
999+ // fill bg
1000+ sBitmapDrawingEngine->FillRect(rect, buttonColorLight1);
1001+
1002+ // treat background color as transparent
1003+ sBitmapDrawingEngine->SetDrawingMode(B_OP_OVER);
1004+ sBitmapDrawingEngine->SetLowColor(buttonColorLight1);
1005+
1006+ if (tab->closePressed) {
1007+ // Draw glint in bottom right, then combined inner and outer
1008+ // shadow in top left.
1009+ // Read the source bitmap in forward while writing the
1010+ // destination in reverse to rotate the bitmap by 180°.
1011+
1012+ data = fGlintBitmap->Bits();
1013+ size = sizeof(kGlintBits);
1014+ for (size_t i = 0; i < size; i++) {
1015+ offset = (size - 1 - i) * 4;
1016+ if (kGlintBits[i] == 0) {
1017+ // draw glint color
1018+ data[offset + 0] = buttonColorLight2.blue;
1019+ data[offset + 1] = buttonColorLight2.green;
1020+ data[offset + 2] = buttonColorLight2.red;
1021+ } else {
1022+ // draw background color
1023+ data[offset + 0] = buttonColorLight1.blue;
1024+ data[offset + 1] = buttonColorLight1.green;
1025+ data[offset + 2] = buttonColorLight1.red;
1026+ }
1027+ }
1028+ // glint is 3x3
1029+ const BRect rightBottom(BRect(rect.right - 2, rect.bottom - 2,
1030+ rect.right, rect.bottom));
1031+ sBitmapDrawingEngine->DrawBitmap(fGlintBitmap,
1032+ fGlintBitmap->Bounds(), rightBottom);
1033+
1034+ data = fCloseBitmap->Bits();
1035+ size = sizeof(kOuterShadowBits);
1036+ for (size_t i = 0; i < size; i++) {
1037+ offset = (size - 1 - i) * 4;
1038+ if (kOuterShadowBits[i] == 0) {
1039+ // draw outer shadow
1040+ data[offset + 0] = buttonColorShadow1.blue;
1041+ data[offset + 1] = buttonColorShadow1.green;
1042+ data[offset + 2] = buttonColorShadow1.red;
1043+ } else if (kInnerShadowBits[i] == 0) {
1044+ // draw inner shadow
1045+ data[offset + 0] = buttonColor.blue;
1046+ data[offset + 1] = buttonColor.green;
1047+ data[offset + 2] = buttonColor.red;
1048+ } else {
1049+ // draw background color
1050+ data[offset + 0] = buttonColorLight1.blue;
1051+ data[offset + 1] = buttonColorLight1.green;
1052+ data[offset + 2] = buttonColorLight1.red;
1053+ }
1054+ }
1055+ // shadow is 10x10
1056+ const BRect leftTop(rect.left, rect.top,
1057+ rect.left + 9, rect.top + 9);
1058+ sBitmapDrawingEngine->DrawBitmap(fCloseBitmap,
1059+ fCloseBitmap->Bounds(), leftTop);
1060+ } else {
1061+ // draw glint, then draw combined outer and inner shadows
1062+
1063+ data = fGlintBitmap->Bits();
1064+ size = sizeof(kGlintBits);
1065+ for (size_t i = 0; i < size; i++) {
1066+ offset = i * 4 + 0;
1067+ if (kGlintBits[i] == 0) {
1068+ // draw glint color
1069+ data[offset + 0] = buttonColorLight2.blue;
1070+ data[offset + 1] = buttonColorLight2.green;
1071+ data[offset + 2] = buttonColorLight2.red;
1072+ } else {
1073+ // draw background color
1074+ data[offset + 0] = buttonColorLight1.blue;
1075+ data[offset + 1] = buttonColorLight1.green;
1076+ data[offset + 2] = buttonColorLight1.red;
1077+ }
1078+ }
1079+ // glint is 3x3
1080+ const BRect leftTop(rect.left, rect.top,
1081+ rect.left + 2, rect.top + 2);
1082+ sBitmapDrawingEngine->DrawBitmap(fGlintBitmap,
1083+ fGlintBitmap->Bounds(), leftTop);
1084+
1085+ data = fCloseBitmap->Bits();
1086+ size = sizeof(kOuterShadowBits);
1087+ for (size_t i = 0; i < size; i++) {
1088+ offset = i * 4 + 0;
1089+ if (kOuterShadowBits[i] == 0) {
1090+ // draw outer shadow
1091+ data[offset + 0] = buttonColorShadow1.blue;
1092+ data[offset + 1] = buttonColorShadow1.green;
1093+ data[offset + 2] = buttonColorShadow1.red;
1094+ } else if (kInnerShadowBits[i] == 0) {
1095+ // draw inner shadow
1096+ data[offset + 0] = buttonColor.blue;
1097+ data[offset + 1] = buttonColor.green;
1098+ data[offset + 2] = buttonColor.red;
1099+ } else {
1100+ // draw background color
1101+ data[offset + 0] = buttonColorLight1.blue;
1102+ data[offset + 1] = buttonColorLight1.green;
1103+ data[offset + 2] = buttonColorLight1.red;
1104+ }
1105+ }
1106+ // shadow is 10x10
1107+ const BRect rightBottom(BRect(rect.right - 9, rect.bottom - 9,
1108+ rect.right, rect.bottom));
1109+ sBitmapDrawingEngine->DrawBitmap(fCloseBitmap,
1110+ fCloseBitmap->Bounds(), rightBottom);
1111+ }
1112+
1113+ // restore drawing mode
1114+ sBitmapDrawingEngine->SetDrawingMode(B_OP_COPY);
1115+
1116+ break;
1117+ }
1118+
1119+ case COMPONENT_ZOOM_BUTTON:
1120+ {
1121+ // BeOS R5 shadow2: active: 210, 158, 0 inactive: 187, 187, 187
1122+ rgb_color buttonColorShadow2(buttonColor);
1123+ buttonColorShadow2.red = std::max(0, buttonColor.red - 45),
1124+ buttonColorShadow2.green = std::max(0, buttonColor.green - 45),
1125+ buttonColorShadow2.blue = std::max(0, buttonColor.blue - 45);
1126+
1127+ // fill the background
1128+ sBitmapDrawingEngine->FillRect(rect, buttonColor);
1129+
1130+ // big rect
1131+ BRect bigRect(rect);
1132+ bigRect.left += floorf(width * 3.0f / 14.0f);
1133+ bigRect.top += floorf(height * 3.0f / 14.0f);
1134+
1135+ // small rect
1136+ BRect smallRect(rect);
1137+ smallRect.right -= floorf(width * 5.0f / 14.0f);
1138+ smallRect.bottom -= floorf(height * 5.0f / 14.0f);
1139+
1140+ // draw big rect bevel
1141+ _DrawBevelRect(sBitmapDrawingEngine, bigRect, tab->zoomPressed,
1142+ buttonColorLight2, buttonColorShadow2);
1143+
1144+ if (fCStatus != B_OK) {
1145+ // If we ran out of memory while initializing bitmaps
1146+ // fall back to a linear gradient.
1147+
1148+ // already drew bigRect bevel, fill with linear gradient
1149+ bigRect.InsetBy(1, 1);
1150+ _DrawBlendedRect(sBitmapDrawingEngine, bigRect,
1151+ tab->zoomPressed, buttonColorLight2, buttonColorLight1,
1152+ buttonColor, buttonColorShadow1);
1153+
1154+ // draw small rect bevel then fill with linear gradient
1155+ _DrawBevelRect(sBitmapDrawingEngine, smallRect,
1156+ tab->zoomPressed, buttonColorLight2, buttonColorShadow2);
1157+ if (!tab->zoomPressed) {
1158+ // undraw bottom left and top right corners
1159+ sBitmapDrawingEngine->StrokePoint(smallRect.LeftBottom(),
1160+ buttonColor);
1161+ sBitmapDrawingEngine->StrokePoint(smallRect.RightTop(),
1162+ buttonColor);
1163+ }
1164+ smallRect.InsetBy(1, 1);
1165+ _DrawBlendedRect(sBitmapDrawingEngine, smallRect,
1166+ tab->zoomPressed, buttonColorLight2, buttonColorLight1,
1167+ buttonColor, buttonColorShadow1);
1168+
1169+ break;
1170+ }
1171+
1172+ // inset past bevel
1173+ bigRect.InsetBy(2, 2);
1174+
1175+ // fill big rect bg
1176+ sBitmapDrawingEngine->FillRect(bigRect, buttonColorLight1);
1177+
1178+ // some elements are covered by the small rect
1179+ // so only draw the parts that get shown
1180+ if (tab->zoomPressed) {
1181+ // draw glint
1182+ // Read the source bitmap in forward while writing the
1183+ // destination in reverse to rotate the bitmap by 180°.
1184+ data = fGlintBitmap->Bits();
1185+ size = sizeof(kGlintBits);
1186+ for (size_t i = 0; i < sizeof(kGlintBits); i++) {
1187+ offset = (size - 1 - i) * 4;
1188+ if (kGlintBits[i] == 0) {
1189+ // draw glint
1190+ data[offset + 0] = buttonColorLight2.blue;
1191+ data[offset + 1] = buttonColorLight2.green;
1192+ data[offset + 2] = buttonColorLight2.red;
1193+ } else {
1194+ // draw background color
1195+ data[offset + 0] = buttonColorLight1.blue;
1196+ data[offset + 1] = buttonColorLight1.green;
1197+ data[offset + 2] = buttonColorLight1.red;
1198+ }
1199+ }
1200+ // glint is 3x3
1201+ const BRect rightBottom(BRect(bigRect.right - 2,
1202+ bigRect.bottom - 2, bigRect.right, bigRect.bottom));
1203+ sBitmapDrawingEngine->DrawBitmap(fGlintBitmap,
1204+ fGlintBitmap->Bounds(), rightBottom);
1205+ } else {
1206+ // draw combined inner and outer shadow
1207+ data = fBigZoomBitmap->Bits();
1208+ size = sizeof(kBigOuterShadowBits);
1209+ for (size_t i = 0; i < sizeof(kBigOuterShadowBits); i++) {
1210+ offset = i * 4;
1211+ if (kBigOuterShadowBits[i] == 0) {
1212+ // draw outer shadow
1213+ data[offset + 0] = buttonColorShadow1.blue;
1214+ data[offset + 1] = buttonColorShadow1.green;
1215+ data[offset + 2] = buttonColorShadow1.red;
1216+ } else if (kBigInnerShadowBits[i] == 0) {
1217+ // draw inner shadow
1218+ data[offset + 0] = buttonColor.blue;
1219+ data[offset + 1] = buttonColor.green;
1220+ data[offset + 2] = buttonColor.red;
1221+ } else {
1222+ // draw background color
1223+ data[offset + 0] = buttonColorLight1.blue;
1224+ data[offset + 1] = buttonColorLight1.green;
1225+ data[offset + 2] = buttonColorLight1.red;
1226+ }
1227+ }
1228+ // shadow is 7x7
1229+ const BRect rightBottom(BRect(bigRect.right - 6,
1230+ bigRect.bottom - 6, bigRect.right, bigRect.bottom));
1231+ sBitmapDrawingEngine->DrawBitmap(fBigZoomBitmap,
1232+ fBigZoomBitmap->Bounds(), rightBottom);
1233+ }
1234+
1235+ sBitmapDrawingEngine->SetDrawingMode(B_OP_COPY);
1236+
1237+ // draw small rect bevel
1238+ _DrawBevelRect(sBitmapDrawingEngine, smallRect, tab->zoomPressed,
1239+ buttonColorLight2, buttonColorShadow2);
1240+
1241+ if (!tab->zoomPressed) {
1242+ // undraw bottom left and top right corners
1243+ sBitmapDrawingEngine->StrokePoint(smallRect.LeftBottom(),
1244+ buttonColor);
1245+ sBitmapDrawingEngine->StrokePoint(smallRect.RightTop(),
1246+ buttonColor);
1247+ }
1248+
1249+ // inset past bevel
1250+ smallRect.InsetBy(2, 2);
1251+
1252+ // fill small rect bg
1253+ sBitmapDrawingEngine->FillRect(smallRect, buttonColorLight1);
1254+
1255+ // treat background color as transparent
1256+ sBitmapDrawingEngine->SetDrawingMode(B_OP_OVER);
1257+ sBitmapDrawingEngine->SetLowColor(buttonColorLight1);
1258+
1259+ // draw small bitmap
1260+ data = fSmallZoomBitmap->Bits();
1261+ size = sizeof(kSmallOuterShadowBits);
1262+ if (tab->zoomPressed) {
1263+ // draw combined inner and outer shadow
1264+ // Read the source bitmap in forward while writing the
1265+ // destination in reverse to rotate the bitmap by 180°.
1266+ for (size_t i = 0; i < size; i++) {
1267+ offset = (size - 1 - i) * 4;
1268+ if (kSmallOuterShadowBits[i] == 0) {
1269+ // draw outer shadow
1270+ data[offset + 0] = buttonColorShadow1.blue;
1271+ data[offset + 1] = buttonColorShadow1.green;
1272+ data[offset + 2] = buttonColorShadow1.red;
1273+ } else if (kSmallInnerShadowBits[i] == 0) {
1274+ // draw inner shadow
1275+ data[offset + 0] = buttonColor.blue;
1276+ data[offset + 1] = buttonColor.green;
1277+ data[offset + 2] = buttonColor.red;
1278+ } else {
1279+ // draw background color
1280+ data[offset + 0] = buttonColorLight1.blue;
1281+ data[offset + 1] = buttonColorLight1.green;
1282+ data[offset + 2] = buttonColorLight1.red;
1283+ }
1284+ }
1285+ // shadow is 5x5
1286+ const BRect smallLeftTop(BRect(smallRect.left,
1287+ smallRect.top, smallRect.left + 4, smallRect.top + 4));
1288+ sBitmapDrawingEngine->DrawBitmap(fSmallZoomBitmap,
1289+ fSmallZoomBitmap->Bounds(), smallLeftTop);
1290+ } else {
1291+ // draw combined inner and outer shadow
1292+ for (size_t i = 0; i < size; i++) {
1293+ offset = i * 4;
1294+ if (kSmallOuterShadowBits[i] == 0) {
1295+ // draw outer shadow
1296+ data[offset + 0] = buttonColorShadow1.blue;
1297+ data[offset + 1] = buttonColorShadow1.green;
1298+ data[offset + 2] = buttonColorShadow1.red;
1299+ } else if (kSmallInnerShadowBits[i] == 0) {
1300+ // draw inner shadow
1301+ data[offset + 0] = buttonColor.blue;
1302+ data[offset + 1] = buttonColor.green;
1303+ data[offset + 2] = buttonColor.red;
1304+ } else {
1305+ // draw background color
1306+ data[offset + 0] = buttonColorLight1.blue;
1307+ data[offset + 1] = buttonColorLight1.green;
1308+ data[offset + 2] = buttonColorLight1.red;
1309+ }
1310+ }
1311+ // shadow is 5x5
1312+ const BRect smallRightBottom(BRect(smallRect.right - 4,
1313+ smallRect.bottom - 4, smallRect.right, smallRect.bottom));
1314+ sBitmapDrawingEngine->DrawBitmap(fSmallZoomBitmap,
1315+ fSmallZoomBitmap->Bounds(), smallRightBottom);
1316+ }
1317+
1318+ // draw glint last (single pixel)
1319+ sBitmapDrawingEngine->StrokePoint(tab->zoomPressed
1320+ ? smallRect.RightBottom() : smallRect.LeftTop(),
1321+ buttonColorLight2);
1322+
1323+ // restore drawing mode
1324+ sBitmapDrawingEngine->SetDrawingMode(B_OP_COPY);
1325+
1326+ break;
1327+ }
1328+
1329+ default:
1330+ break;
1331+ }
1332+
1333+ UtilityBitmap* bitmap = sBitmapDrawingEngine->ExportToBitmap(width, height,
1334+ B_RGB32);
1335+ if (bitmap == NULL)
1336+ return NULL;
1337+
1338+ // bitmap ready, put it into the list
1339+ decorator_bitmap* entry = new(std::nothrow) decorator_bitmap;
1340+ if (entry == NULL) {
1341+ delete bitmap;
1342+ return NULL;
1343+ }
1344+
1345+ entry->item = item;
1346+ entry->down = down;
1347+ entry->width = width;
1348+ entry->height = height;
1349+ entry->bitmap = bitmap;
1350+ entry->baseColor = colors[COLOR_BUTTON];
1351+ entry->lightColor = colors[COLOR_BUTTON_LIGHT];
1352+ entry->next = sBitmapList;
1353+ sBitmapList = entry;
1354+ return bitmap;
1355+}
1356+
1357+
1358+ServerBitmap*
1359+BeDecorator::_CreateTemporaryBitmap(BRect bounds) const
1360+{
1361+ UtilityBitmap* bitmap = new(std::nothrow) UtilityBitmap(bounds,
1362+ B_RGB32, 0);
1363+ if (bitmap == NULL)
1364+ return NULL;
1365+
1366+ if (!bitmap->IsValid()) {
1367+ delete bitmap;
1368+ return NULL;
1369+ }
1370+
1371+ memset(bitmap->Bits(), 0, bitmap->BitsLength());
1372+ // background opacity is 0
1373+
1374+ return bitmap;
1375+}
1376+
1377+
1378+void
1379+BeDecorator::_GetComponentColors(Component component,
1380+ ComponentColors _colors, Decorator::Tab* tab)
1381+{
1382+ // get the highlight for our component
1383+ Region region = REGION_NONE;
1384+ switch (component) {
1385+ case COMPONENT_TAB:
1386+ region = REGION_TAB;
1387+ break;
1388+ case COMPONENT_CLOSE_BUTTON:
1389+ region = REGION_CLOSE_BUTTON;
1390+ break;
1391+ case COMPONENT_ZOOM_BUTTON:
1392+ region = REGION_ZOOM_BUTTON;
1393+ break;
1394+ case COMPONENT_LEFT_BORDER:
1395+ region = REGION_LEFT_BORDER;
1396+ break;
1397+ case COMPONENT_RIGHT_BORDER:
1398+ region = REGION_RIGHT_BORDER;
1399+ break;
1400+ case COMPONENT_TOP_BORDER:
1401+ region = REGION_TOP_BORDER;
1402+ break;
1403+ case COMPONENT_BOTTOM_BORDER:
1404+ region = REGION_BOTTOM_BORDER;
1405+ break;
1406+ case COMPONENT_RESIZE_CORNER:
1407+ region = REGION_RIGHT_BOTTOM_CORNER;
1408+ break;
1409+ }
1410+
1411+ return GetComponentColors(component, RegionHighlight(region), _colors, tab);
1412+}
1413+
1414+
1415+extern "C" DecorAddOn* (instantiate_decor_addon)(image_id id, const char* name)
1416+{
1417+ return new (std::nothrow)BeDecorAddOn(id, name);
1418+}
+87,
-0
1@@ -0,0 +1,87 @@
2+/*
3+ * Copyright 2001-2013 Haiku, Inc. All rights reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * John Scipione, jscipione@gmail.com
10+ * Clemens Zeidler, haiku@clemens-zeidler.de
11+ */
12+#ifndef BE_DECORATOR_H
13+#define BE_DECORATOR_H
14+
15+
16+#include "DecorManager.h"
17+#include "SATDecorator.h"
18+
19+
20+class Desktop;
21+class ServerBitmap;
22+
23+
24+class BeDecorAddOn : public DecorAddOn {
25+public:
26+ BeDecorAddOn(image_id id, const char* name);
27+
28+protected:
29+ virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
30+ BRect rect, Desktop* desktop);
31+};
32+
33+
34+class BeDecorator: public SATDecorator {
35+public:
36+ BeDecorator(DesktopSettings& settings,
37+ BRect frame, Desktop* desktop);
38+ virtual ~BeDecorator();
39+
40+ virtual void GetComponentColors(Component component,
41+ uint8 highlight, ComponentColors _colors,
42+ Decorator::Tab* tab = NULL);
43+
44+protected:
45+ virtual void _DrawFrame(BRect rect);
46+
47+ virtual void _DrawTab(Decorator::Tab* tab, BRect rect);
48+ virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
49+ virtual void _DrawClose(Decorator::Tab* tab, bool direct,
50+ BRect rect);
51+ virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
52+ BRect rect);
53+ virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
54+ BRect rect);
55+
56+ virtual void _GetButtonSizeAndOffset(const BRect& tabRect,
57+ float* offset, float* size,
58+ float* inset) const;
59+
60+private:
61+ void _DrawBevelRect(DrawingEngine* engine,
62+ const BRect rect, bool down,
63+ rgb_color light, rgb_color shadow);
64+ void _DrawBlendedRect(DrawingEngine* engine,
65+ const BRect rect, bool down,
66+ rgb_color colorA, rgb_color colorB,
67+ rgb_color colorC, rgb_color colorD);
68+ void _DrawButtonBitmap(ServerBitmap* bitmap,
69+ bool direct, BRect rect);
70+ ServerBitmap* _GetBitmapForButton(Decorator::Tab* tab,
71+ Component item, bool down, int32 width,
72+ int32 height);
73+ ServerBitmap* _CreateTemporaryBitmap(BRect bounds) const;
74+ void _GetComponentColors(Component component,
75+ ComponentColors _colors,
76+ Decorator::Tab* tab = NULL);
77+
78+private:
79+ status_t fCStatus;
80+
81+ ServerBitmap* fCloseBitmap;
82+ ServerBitmap* fBigZoomBitmap;
83+ ServerBitmap* fSmallZoomBitmap;
84+ ServerBitmap* fGlintBitmap;
85+};
86+
87+
88+#endif // BE_DECORATOR_H
+383,
-0
1@@ -0,0 +1,383 @@
2+/*
3+ * Copyright (c) 2001-2020 Haiku, Inc. All right reserved.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Author:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Clemens Zeidler <haiku@clemens-zeidler.de>
9+ * Joseph Groover <looncraz@satx.rr.com>
10+ * John Scipione <jscipione@gmail.com>
11+ */
12+
13+#include "DecorManager.h"
14+
15+#include <Directory.h>
16+#include <Entry.h>
17+#include <File.h>
18+#include <FindDirectory.h>
19+#include <Message.h>
20+#include <Path.h>
21+#include <Rect.h>
22+
23+#include <syslog.h>
24+
25+#include "AppServer.h"
26+#include "Desktop.h"
27+#include "DesktopSettings.h"
28+#include "ServerConfig.h"
29+#include "SATDecorator.h"
30+#include "Window.h"
31+
32+typedef float get_version(void);
33+typedef DecorAddOn* create_decor_addon(image_id id, const char* name);
34+
35+// Globals
36+DecorManager gDecorManager;
37+
38+
39+DecorAddOn::DecorAddOn(image_id id, const char* name)
40+ :
41+ fImageID(id),
42+ fName(name)
43+{
44+}
45+
46+
47+DecorAddOn::~DecorAddOn()
48+{
49+}
50+
51+
52+status_t
53+DecorAddOn::InitCheck() const
54+{
55+ return B_OK;
56+}
57+
58+
59+Decorator*
60+DecorAddOn::AllocateDecorator(Desktop* desktop, DrawingEngine* engine,
61+ BRect rect, const char* title, window_look look, uint32 flags)
62+{
63+ if (!desktop->LockSingleWindow())
64+ return NULL;
65+
66+ DesktopSettings settings(desktop);
67+ Decorator* decorator;
68+ decorator = _AllocateDecorator(settings, rect, desktop);
69+ desktop->UnlockSingleWindow();
70+ if (!decorator)
71+ return NULL;
72+
73+ decorator->UpdateColors(settings);
74+
75+ if (decorator->AddTab(settings, title, look, flags) == NULL) {
76+ delete decorator;
77+ return NULL;
78+ }
79+
80+ decorator->SetDrawingEngine(engine);
81+ return decorator;
82+}
83+
84+
85+WindowBehaviour*
86+DecorAddOn::AllocateWindowBehaviour(Window* window)
87+{
88+ return new (std::nothrow)SATWindowBehaviour(window,
89+ window->Desktop()->GetStackAndTile());
90+}
91+
92+
93+const DesktopListenerList&
94+DecorAddOn::GetDesktopListeners()
95+{
96+ return fDesktopListeners;
97+}
98+
99+
100+Decorator*
101+DecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect,
102+ Desktop* desktop)
103+{
104+ return new (std::nothrow)SATDecorator(settings, rect, desktop);
105+}
106+
107+
108+// #pragma mark -
109+
110+
111+DecorManager::DecorManager()
112+ :
113+ fDefaultDecor(-1, "Default"),
114+ fCurrentDecor(&fDefaultDecor),
115+ fPreviewDecor(NULL),
116+ fPreviewWindow(NULL),
117+ fCurrentDecorPath("Default")
118+{
119+ _LoadSettingsFromDisk();
120+}
121+
122+
123+DecorManager::~DecorManager()
124+{
125+}
126+
127+
128+Decorator*
129+DecorManager::AllocateDecorator(Window* window)
130+{
131+ // Create a new instance of the current decorator.
132+ // Ownership is that of the caller
133+
134+ if (!fCurrentDecor) {
135+ // We should *never* be here. If we do, it's a bug.
136+ debugger("DecorManager::AllocateDecorator has a NULL decorator");
137+ return NULL;
138+ }
139+
140+ // Are we previewing a specific decorator?
141+ if (window == fPreviewWindow) {
142+ if (fPreviewDecor != NULL) {
143+ return fPreviewDecor->AllocateDecorator(window->Desktop(),
144+ window->GetDrawingEngine(), window->Frame(), window->Title(),
145+ window->Look(), window->Flags());
146+ } else {
147+ fPreviewWindow = NULL;
148+ }
149+ }
150+
151+ return fCurrentDecor->AllocateDecorator(window->Desktop(),
152+ window->GetDrawingEngine(), window->Frame(), window->Title(),
153+ window->Look(), window->Flags());
154+}
155+
156+
157+WindowBehaviour*
158+DecorManager::AllocateWindowBehaviour(Window* window)
159+{
160+ if (!fCurrentDecor) {
161+ // We should *never* be here. If we do, it's a bug.
162+ debugger("DecorManager::AllocateDecorator has a NULL decorator");
163+ return NULL;
164+ }
165+
166+ return fCurrentDecor->AllocateWindowBehaviour(window);
167+}
168+
169+
170+void
171+DecorManager::CleanupForWindow(Window* window)
172+{
173+ // Given window is being deleted, do any cleanup needed
174+ if (fPreviewWindow == window && window != NULL){
175+ fPreviewWindow = NULL;
176+
177+ if (fPreviewDecor != NULL)
178+ unload_add_on(fPreviewDecor->ImageID());
179+
180+ fPreviewDecor = NULL;
181+ }
182+}
183+
184+
185+status_t
186+DecorManager::PreviewDecorator(BString path, Window* window)
187+{
188+ if (fPreviewWindow != NULL && fPreviewWindow != window){
189+ // Reset other window to current decorator - only one can preview
190+ Window* oldPreviewWindow = fPreviewWindow;
191+ fPreviewWindow = NULL;
192+ oldPreviewWindow->ReloadDecor();
193+ }
194+
195+ if (window == NULL)
196+ return B_BAD_VALUE;
197+
198+ // We have to jump some hoops because the window must be able to
199+ // delete its decorator before we unload the add-on
200+ status_t error = B_OK;
201+ DecorAddOn* decorPtr = _LoadDecor(path, error);
202+ if (decorPtr == NULL)
203+ return error == B_OK ? B_ERROR : error;
204+
205+ BRegion border;
206+ window->GetBorderRegion(&border);
207+
208+ DecorAddOn* oldDecor = fPreviewDecor;
209+ fPreviewDecor = decorPtr;
210+ fPreviewWindow = window;
211+ // After this call, the window has deleted its decorator.
212+ fPreviewWindow->ReloadDecor();
213+
214+ BRegion newBorder;
215+ window->GetBorderRegion(&newBorder);
216+
217+ border.Include(&newBorder);
218+ window->Desktop()->RebuildAndRedrawAfterWindowChange(window, border);
219+
220+ if (oldDecor != NULL)
221+ unload_add_on(oldDecor->ImageID());
222+
223+ return B_OK;
224+}
225+
226+
227+const DesktopListenerList&
228+DecorManager::GetDesktopListeners()
229+{
230+ return fCurrentDecor->GetDesktopListeners();
231+}
232+
233+
234+BString
235+DecorManager::GetCurrentDecorator() const
236+{
237+ return fCurrentDecorPath.String();
238+}
239+
240+
241+status_t
242+DecorManager::SetDecorator(BString path, Desktop* desktop)
243+{
244+ status_t error = B_OK;
245+ DecorAddOn* newDecor = _LoadDecor(path, error);
246+ if (newDecor == NULL)
247+ return error == B_OK ? B_ERROR : error;
248+
249+ DecorAddOn* oldDecor = fCurrentDecor;
250+
251+ BString oldPath = fCurrentDecorPath;
252+ image_id oldImage = fCurrentDecor->ImageID();
253+
254+ fCurrentDecor = newDecor;
255+ fCurrentDecorPath = path.String();
256+
257+ if (desktop->ReloadDecor(oldDecor)) {
258+ // now safe to unload all old decorator data
259+ // saves us from deleting oldDecor...
260+ unload_add_on(oldImage);
261+ _SaveSettingsToDisk();
262+ return B_OK;
263+ }
264+
265+ // TODO: unloading the newDecor and its image
266+ // problem is we don't know how many windows failed... or why they failed...
267+ syslog(LOG_WARNING,
268+ "app_server:DecorManager:SetDecorator:\"%s\" *partly* failed\n",
269+ fCurrentDecorPath.String());
270+
271+ fCurrentDecor = oldDecor;
272+ fCurrentDecorPath = oldPath;
273+ return B_ERROR;
274+}
275+
276+
277+DecorAddOn*
278+DecorManager::_LoadDecor(BString _path, status_t& error )
279+{
280+ if (_path == "Default") {
281+ error = B_OK;
282+ return &fDefaultDecor;
283+ }
284+
285+ BEntry entry(_path.String(), true);
286+ if (!entry.Exists()) {
287+ error = B_ENTRY_NOT_FOUND;
288+ return NULL;
289+ }
290+
291+ BPath path(&entry);
292+ image_id image = load_add_on(path.Path());
293+ if (image < 0) {
294+ error = B_BAD_IMAGE_ID;
295+ return NULL;
296+ }
297+
298+ create_decor_addon* createFunc;
299+ if (get_image_symbol(image, "instantiate_decor_addon", B_SYMBOL_TYPE_TEXT,
300+ (void**)&createFunc) != B_OK) {
301+ unload_add_on(image);
302+ error = B_MISSING_SYMBOL;
303+ return NULL;
304+ }
305+
306+ char name[B_FILE_NAME_LENGTH];
307+ entry.GetName(name);
308+ DecorAddOn* newDecor = createFunc(image, name);
309+ if (newDecor == NULL || newDecor->InitCheck() != B_OK) {
310+ unload_add_on(image);
311+ error = B_ERROR;
312+ return NULL;
313+ }
314+
315+ return newDecor;
316+}
317+
318+
319+static const char* kSettingsDir = "system/app_server";
320+static const char* kSettingsFile = "decorator_settings";
321+
322+
323+bool
324+DecorManager::_LoadSettingsFromDisk()
325+{
326+ // get the user settings directory
327+ BPath path;
328+ status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
329+ if (error != B_OK)
330+ return false;
331+
332+ path.Append(kSettingsDir);
333+ path.Append(kSettingsFile);
334+ BFile file(path.Path(), B_READ_ONLY);
335+ if (file.InitCheck() != B_OK)
336+ return false;
337+
338+ BMessage settings;
339+ if (settings.Unflatten(&file) == B_OK) {
340+ BString itemPath;
341+ if (settings.FindString("decorator", &itemPath) == B_OK) {
342+ status_t error = B_OK;
343+ DecorAddOn* decor = _LoadDecor(itemPath, error);
344+ if (decor != NULL) {
345+ fCurrentDecor = decor;
346+ fCurrentDecorPath = itemPath;
347+ return true;
348+ } else {
349+ //TODO: do something with the reported error
350+ }
351+ }
352+ }
353+
354+ return false;
355+}
356+
357+
358+bool
359+DecorManager::_SaveSettingsToDisk()
360+{
361+ // get the user settings directory
362+ BPath path;
363+ status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
364+ if (error != B_OK)
365+ return false;
366+
367+ path.Append(kSettingsDir);
368+ if (create_directory(path.Path(), 777) != B_OK)
369+ return false;
370+
371+ path.Append(kSettingsFile);
372+ BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
373+ if (file.InitCheck() != B_OK)
374+ return false;
375+
376+ BMessage settings;
377+ if (settings.AddString("decorator", fCurrentDecorPath.String()) != B_OK)
378+ return false;
379+ if (settings.Flatten(&file) != B_OK)
380+ return false;
381+
382+ return true;
383+}
384+
+98,
-0
1@@ -0,0 +1,98 @@
2+/*
3+ * Copyright (c) 2001-2005, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Author:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Clemens Zeidler <haiku@clemens-zeidler.de>
9+ * Joseph Groover <looncraz@satx.rr.com>
10+ */
11+#ifndef DECOR_MANAGER_H
12+#define DECOR_MANAGER_H
13+
14+
15+#include <image.h>
16+#include <String.h>
17+#include <Locker.h>
18+#include <ObjectList.h>
19+#include <Entry.h>
20+#include <DecorInfo.h>
21+
22+#include "Decorator.h"
23+
24+class Desktop;
25+class DesktopListener;
26+class DrawingEngine;
27+class Window;
28+class WindowBehaviour;
29+
30+
31+typedef BObjectList<DesktopListener> DesktopListenerList;
32+
33+
34+// special name to test for use of non-fs-tied default decorator
35+// this just keeps things clean and simple is all
36+
37+class DecorAddOn {
38+public:
39+ DecorAddOn(image_id id, const char* name);
40+ virtual ~DecorAddOn();
41+
42+ virtual status_t InitCheck() const;
43+
44+ image_id ImageID() const { return fImageID; }
45+
46+ Decorator* AllocateDecorator(Desktop* desktop,
47+ DrawingEngine* engine, BRect rect,
48+ const char* title, window_look look,
49+ uint32 flags);
50+
51+ virtual WindowBehaviour* AllocateWindowBehaviour(Window* window);
52+
53+ virtual const DesktopListenerList& GetDesktopListeners();
54+
55+protected:
56+ virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
57+ BRect rect, Desktop* desktop);
58+
59+ DesktopListenerList fDesktopListeners;
60+
61+private:
62+ image_id fImageID;
63+ BString fName;
64+};
65+
66+
67+class DecorManager {
68+public:
69+ DecorManager();
70+ ~DecorManager();
71+
72+ Decorator* AllocateDecorator(Window *window);
73+ WindowBehaviour* AllocateWindowBehaviour(Window *window);
74+ void CleanupForWindow(Window *window);
75+
76+ status_t PreviewDecorator(BString path, Window *window);
77+
78+ const DesktopListenerList& GetDesktopListeners();
79+
80+ BString GetCurrentDecorator() const;
81+ status_t SetDecorator(BString path, Desktop *desktop);
82+
83+private:
84+ DecorAddOn* _LoadDecor(BString path, status_t &error);
85+ bool _LoadSettingsFromDisk();
86+ bool _SaveSettingsToDisk();
87+
88+private:
89+ DecorAddOn fDefaultDecor;
90+ DecorAddOn* fCurrentDecor;
91+ DecorAddOn* fPreviewDecor;
92+
93+ Window* fPreviewWindow;
94+ BString fCurrentDecorPath;
95+};
96+
97+extern DecorManager gDecorManager;
98+
99+#endif /* DECOR_MANAGER_H */
+1229,
-0
1@@ -0,0 +1,1229 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * John Scipione, jscipione@gmail.com
10+ * Ingo Weinhold, ingo_weinhold@gmx.de
11+ * Clemens Zeidler, haiku@clemens-zeidler.de
12+ * Joseph Groover, looncraz@looncraz.net
13+ * Tri-Edge AI
14+ * Jacob Secunda, secundja@gmail.com
15+ */
16+
17+
18+/*! Base class for window decorators */
19+
20+
21+#include "Decorator.h"
22+
23+#include <stdio.h>
24+
25+#include <Region.h>
26+
27+#include "Desktop.h"
28+#include "DesktopSettings.h"
29+#include "DrawingEngine.h"
30+
31+
32+Decorator::Tab::Tab()
33+ :
34+ tabRect(),
35+
36+ zoomRect(),
37+ closeRect(),
38+ minimizeRect(),
39+
40+ closePressed(false),
41+ zoomPressed(false),
42+ minimizePressed(false),
43+
44+ look(B_TITLED_WINDOW_LOOK),
45+ flags(0),
46+ isFocused(false),
47+ title(""),
48+
49+ tabOffset(0),
50+ tabLocation(0.0f),
51+ textOffset(10.0f),
52+
53+ truncatedTitle(""),
54+ truncatedTitleLength(0),
55+
56+ buttonFocus(false),
57+ isHighlighted(false),
58+
59+ minTabSize(0.0f),
60+ maxTabSize(0.0f)
61+{
62+ closeBitmaps[0] = closeBitmaps[1] = closeBitmaps[2] = closeBitmaps[3]
63+ = minimizeBitmaps[0] = minimizeBitmaps[1] = minimizeBitmaps[2]
64+ = minimizeBitmaps[3] = zoomBitmaps[0] = zoomBitmaps[1] = zoomBitmaps[2]
65+ = zoomBitmaps[3] = NULL;
66+}
67+
68+
69+/*! \brief Constructor
70+
71+ Does general initialization of internal data members and creates a colorset
72+ object.
73+
74+ \param settings DesktopSettings pointer.
75+ \param frame Decorator frame rectangle
76+*/
77+Decorator::Decorator(DesktopSettings& settings, BRect frame,
78+ Desktop* desktop)
79+ :
80+ fLocker("Decorator"),
81+
82+ fDrawingEngine(NULL),
83+ fDrawState(),
84+
85+ fTitleBarRect(),
86+ fFrame(frame),
87+ fResizeRect(),
88+ fBorderRect(),
89+ fOutlineBorderRect(),
90+
91+ fLeftBorder(),
92+ fTopBorder(),
93+ fBottomBorder(),
94+ fRightBorder(),
95+
96+ fLeftOutlineBorder(),
97+ fTopOutlineBorder(),
98+ fBottomOutlineBorder(),
99+ fRightOutlineBorder(),
100+
101+ fBorderWidth(-1),
102+ fOutlineBorderWidth(-1),
103+
104+ fTopTab(NULL),
105+
106+ fDesktop(desktop),
107+ fFootprintValid(false)
108+{
109+ memset(&fRegionHighlights, HIGHLIGHT_NONE, sizeof(fRegionHighlights));
110+}
111+
112+
113+/*! \brief Destructor
114+
115+ Frees the color set and the title string
116+*/
117+Decorator::~Decorator()
118+{
119+}
120+
121+
122+Decorator::Tab*
123+Decorator::AddTab(DesktopSettings& settings, const char* title,
124+ window_look look, uint32 flags, int32 index, BRegion* updateRegion)
125+{
126+ AutoWriteLocker _(fLocker);
127+
128+ Decorator::Tab* tab = _AllocateNewTab();
129+ if (tab == NULL)
130+ return NULL;
131+ tab->title = title;
132+ tab->look = look;
133+ tab->flags = flags;
134+
135+ bool ok = false;
136+ if (index >= 0) {
137+ if (fTabList.AddItem(tab, index) == true)
138+ ok = true;
139+ } else if (fTabList.AddItem(tab) == true)
140+ ok = true;
141+
142+ if (ok == false) {
143+ delete tab;
144+ return NULL;
145+ }
146+
147+ Decorator::Tab* oldTop = fTopTab;
148+ fTopTab = tab;
149+ if (_AddTab(settings, index, updateRegion) == false) {
150+ fTabList.RemoveItem(tab);
151+ delete tab;
152+ fTopTab = oldTop;
153+ return NULL;
154+ }
155+
156+ _InvalidateFootprint();
157+ return tab;
158+}
159+
160+
161+bool
162+Decorator::RemoveTab(int32 index, BRegion* updateRegion)
163+{
164+ AutoWriteLocker _(fLocker);
165+
166+ Decorator::Tab* tab = fTabList.RemoveItemAt(index);
167+ if (tab == NULL)
168+ return false;
169+
170+ _RemoveTab(index, updateRegion);
171+
172+ delete tab;
173+ _InvalidateFootprint();
174+ return true;
175+}
176+
177+
178+bool
179+Decorator::MoveTab(int32 from, int32 to, bool isMoving, BRegion* updateRegion)
180+{
181+ AutoWriteLocker _(fLocker);
182+
183+ if (_MoveTab(from, to, isMoving, updateRegion) == false)
184+ return false;
185+ if (fTabList.MoveItem(from, to) == false) {
186+ // move the tab back
187+ _MoveTab(from, to, isMoving, updateRegion);
188+ return false;
189+ }
190+ return true;
191+}
192+
193+
194+int32
195+Decorator::TabAt(const BPoint& where) const
196+{
197+ AutoReadLocker _(fLocker);
198+
199+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
200+ Decorator::Tab* tab = fTabList.ItemAt(i);
201+ if (tab->tabRect.Contains(where))
202+ return i;
203+ }
204+
205+ return -1;
206+}
207+
208+
209+void
210+Decorator::SetTopTab(int32 tab)
211+{
212+ AutoWriteLocker _(fLocker);
213+ fTopTab = fTabList.ItemAt(tab);
214+}
215+
216+
217+/*! \brief Assigns a display driver to the decorator
218+ \param driver A valid DrawingEngine object
219+*/
220+void
221+Decorator::SetDrawingEngine(DrawingEngine* engine)
222+{
223+ AutoWriteLocker _(fLocker);
224+
225+ fDrawingEngine = engine;
226+ // lots of subclasses will depend on the driver for text support, so call
227+ // _DoLayout() after we have it
228+ if (fDrawingEngine != NULL) {
229+ _DoLayout();
230+ _DoOutlineLayout();
231+ }
232+}
233+
234+
235+/*! \brief Sets the decorator's window flags
236+
237+ While this call will not update the screen, it will affect how future
238+ updates work and immediately affects input handling.
239+
240+ \param flags New value for the flags
241+*/
242+void
243+Decorator::SetFlags(int32 tab, uint32 flags, BRegion* updateRegion)
244+{
245+ AutoWriteLocker _(fLocker);
246+
247+ // we're nice to our subclasses - we make sure B_NOT_{H|V|}_RESIZABLE
248+ // are in sync (it's only a semantical simplification, not a necessity)
249+ if ((flags & (B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE))
250+ == (B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE))
251+ flags |= B_NOT_RESIZABLE;
252+ if (flags & B_NOT_RESIZABLE)
253+ flags |= B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE;
254+
255+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
256+ if (decoratorTab == NULL)
257+ return;
258+ _SetFlags(decoratorTab, flags, updateRegion);
259+ _InvalidateFootprint();
260+ // the border might have changed (smaller/larger tab)
261+}
262+
263+
264+/*! \brief Called whenever the system fonts are changed.
265+*/
266+void
267+Decorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
268+{
269+ AutoWriteLocker _(fLocker);
270+
271+ _FontsChanged(settings, updateRegion);
272+ _InvalidateFootprint();
273+}
274+
275+
276+/*! \brief Called when a system colors change.
277+*/
278+void
279+Decorator::ColorsChanged(DesktopSettings& settings, BRegion* updateRegion)
280+{
281+ AutoWriteLocker _(fLocker);
282+
283+ UpdateColors(settings);
284+
285+ if (updateRegion != NULL)
286+ updateRegion->Include(&GetFootprint());
287+
288+ _InvalidateBitmaps();
289+}
290+
291+
292+/*! \brief Sets the decorator's window look
293+ \param look New value for the look
294+*/
295+void
296+Decorator::SetLook(int32 tab, DesktopSettings& settings, window_look look,
297+ BRegion* updateRect)
298+{
299+ AutoWriteLocker _(fLocker);
300+
301+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
302+ if (decoratorTab == NULL)
303+ return;
304+
305+ _SetLook(decoratorTab, settings, look, updateRect);
306+ _InvalidateFootprint();
307+ // the border very likely changed
308+}
309+
310+
311+/*! \brief Returns the decorator's window look
312+ \return the decorator's window look
313+*/
314+window_look
315+Decorator::Look(int32 tab) const
316+{
317+ AutoReadLocker _(fLocker);
318+ return TabAt(tab)->look;
319+}
320+
321+
322+/*! \brief Returns the decorator's window flags
323+ \return the decorator's window flags
324+*/
325+uint32
326+Decorator::Flags(int32 tab) const
327+{
328+ AutoReadLocker _(fLocker);
329+ return TabAt(tab)->flags;
330+}
331+
332+
333+/*! \brief Returns the decorator's border rectangle
334+ \return the decorator's border rectangle
335+*/
336+BRect
337+Decorator::BorderRect() const
338+{
339+ AutoReadLocker _(fLocker);
340+ return fBorderRect;
341+}
342+
343+
344+BRect
345+Decorator::TitleBarRect() const
346+{
347+ AutoReadLocker _(fLocker);
348+ return fTitleBarRect;
349+}
350+
351+
352+/*! \brief Returns the decorator's tab rectangle
353+ \return the decorator's tab rectangle
354+*/
355+BRect
356+Decorator::TabRect(int32 tab) const
357+{
358+ AutoReadLocker _(fLocker);
359+
360+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
361+ if (decoratorTab == NULL)
362+ return BRect();
363+ return decoratorTab->tabRect;
364+}
365+
366+
367+BRect
368+Decorator::TabRect(Decorator::Tab* tab) const
369+{
370+ return tab->tabRect;
371+}
372+
373+
374+/*! \brief Sets the close button's value.
375+
376+ Note that this does not update the button's look - it just updates the
377+ internal button value
378+
379+ \param tab The tab index
380+ \param pressed Whether the button is down or not
381+*/
382+void
383+Decorator::SetClose(int32 tab, bool pressed)
384+{
385+ AutoWriteLocker _(fLocker);
386+
387+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
388+ if (decoratorTab == NULL)
389+ return;
390+
391+ if (pressed != decoratorTab->closePressed) {
392+ decoratorTab->closePressed = pressed;
393+ DrawClose(tab);
394+ }
395+}
396+
397+
398+/*! \brief Sets the minimize button's value.
399+
400+ Note that this does not update the button's look - it just updates the
401+ internal button value
402+
403+ \param is_down Whether the button is down or not
404+*/
405+void
406+Decorator::SetMinimize(int32 tab, bool pressed)
407+{
408+ AutoWriteLocker _(fLocker);
409+
410+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
411+ if (decoratorTab == NULL)
412+ return;
413+
414+ if (pressed != decoratorTab->minimizePressed) {
415+ decoratorTab->minimizePressed = pressed;
416+ DrawMinimize(tab);
417+ }
418+}
419+
420+/*! \brief Sets the zoom button's value.
421+
422+ Note that this does not update the button's look - it just updates the
423+ internal button value
424+
425+ \param is_down Whether the button is down or not
426+*/
427+void
428+Decorator::SetZoom(int32 tab, bool pressed)
429+{
430+ AutoWriteLocker _(fLocker);
431+
432+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
433+ if (decoratorTab == NULL)
434+ return;
435+
436+ if (pressed != decoratorTab->zoomPressed) {
437+ decoratorTab->zoomPressed = pressed;
438+ DrawZoom(tab);
439+ }
440+}
441+
442+
443+/*! \brief Updates the value of the decorator title
444+ \param string New title value
445+*/
446+void
447+Decorator::SetTitle(int32 tab, const char* string, BRegion* updateRegion)
448+{
449+ AutoWriteLocker _(fLocker);
450+
451+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
452+ if (decoratorTab == NULL)
453+ return;
454+
455+ decoratorTab->title.SetTo(string);
456+ _SetTitle(decoratorTab, string, updateRegion);
457+
458+ _InvalidateFootprint();
459+ // the border very likely changed
460+
461+ // TODO: redraw?
462+}
463+
464+
465+/*! \brief Returns the decorator's title
466+ \return the decorator's title
467+*/
468+const char*
469+Decorator::Title(int32 tab) const
470+{
471+ AutoReadLocker _(fLocker);
472+
473+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
474+ if (decoratorTab == NULL)
475+ return "";
476+
477+ return decoratorTab->title;
478+}
479+
480+
481+const char*
482+Decorator::Title(Decorator::Tab* tab) const
483+{
484+ AutoReadLocker _(fLocker);
485+ return tab->title;
486+}
487+
488+
489+float
490+Decorator::TabLocation(int32 tab) const
491+{
492+ AutoReadLocker _(fLocker);
493+
494+ Decorator::Tab* decoratorTab = _TabAt(tab);
495+ if (decoratorTab == NULL)
496+ return 0.0f;
497+
498+ return (float)decoratorTab->tabOffset;
499+}
500+
501+
502+bool
503+Decorator::SetTabLocation(int32 tab, float location, bool isShifting,
504+ BRegion* updateRegion)
505+{
506+ AutoWriteLocker _(fLocker);
507+
508+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
509+ if (decoratorTab == NULL)
510+ return false;
511+ if (_SetTabLocation(decoratorTab, location, isShifting, updateRegion)) {
512+ _InvalidateFootprint();
513+ return true;
514+ }
515+ return false;
516+}
517+
518+
519+
520+/*! \brief Changes the focus value of the decorator
521+
522+ While this call will not update the screen, it will affect how future
523+ updates work.
524+
525+ \param active True if active, false if not
526+*/
527+void
528+Decorator::SetFocus(int32 tab, bool active)
529+{
530+ AutoWriteLocker _(fLocker);
531+
532+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
533+ if (decoratorTab == NULL)
534+ return;
535+ decoratorTab->isFocused = active;
536+ _SetFocus(decoratorTab);
537+ // TODO: maybe it would be cleaner to handle the redraw here.
538+}
539+
540+
541+bool
542+Decorator::IsFocus(int32 tab) const
543+{
544+ AutoReadLocker _(fLocker);
545+
546+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
547+ if (decoratorTab == NULL)
548+ return false;
549+
550+ return decoratorTab->isFocused;
551+};
552+
553+
554+bool
555+Decorator::IsFocus(Decorator::Tab* tab) const
556+{
557+ AutoReadLocker _(fLocker);
558+ return tab->isFocused;
559+}
560+
561+
562+// #pragma mark - virtual methods
563+
564+
565+/*! \brief Returns a cached footprint if available otherwise recalculate it
566+*/
567+const BRegion&
568+Decorator::GetFootprint()
569+{
570+ AutoReadLocker _(fLocker);
571+
572+ if (!fFootprintValid) {
573+ fFootprint.MakeEmpty();
574+
575+ _GetFootprint(&fFootprint);
576+
577+ if (IsOutlineResizing())
578+ _GetOutlineFootprint(&fFootprint);
579+
580+ fFootprintValid = true;
581+ }
582+
583+ return fFootprint;
584+}
585+
586+
587+/*! \brief Returns our Desktop object pointer
588+*/
589+::Desktop*
590+Decorator::GetDesktop()
591+{
592+ AutoReadLocker _(fLocker);
593+ return fDesktop;
594+}
595+
596+
597+/*! \brief Performs hit-testing for the decorator.
598+
599+ The base class provides a basic implementation, recognizing only button and
600+ tab hits. Derived classes must override/enhance it to handle borders and
601+ corners correctly.
602+
603+ \param where The point to be tested.
604+ \return Either of the following, depending on what was hit:
605+ - \c REGION_NONE: None of the decorator regions.
606+ - \c REGION_TAB: The window tab (but none of the buttons embedded).
607+ - \c REGION_CLOSE_BUTTON: The close button.
608+ - \c REGION_ZOOM_BUTTON: The zoom button.
609+ - \c REGION_MINIMIZE_BUTTON: The minimize button.
610+ - \c REGION_LEFT_BORDER: The left border.
611+ - \c REGION_RIGHT_BORDER: The right border.
612+ - \c REGION_TOP_BORDER: The top border.
613+ - \c REGION_BOTTOM_BORDER: The bottom border.
614+ - \c REGION_LEFT_TOP_CORNER: The left-top corner.
615+ - \c REGION_LEFT_BOTTOM_CORNER: The left-bottom corner.
616+ - \c REGION_RIGHT_TOP_CORNER: The right-top corner.
617+ - \c REGION_RIGHT_BOTTOM_CORNER The right-bottom corner.
618+*/
619+Decorator::Region
620+Decorator::RegionAt(BPoint where, int32& tabIndex) const
621+{
622+ AutoReadLocker _(fLocker);
623+
624+ tabIndex = -1;
625+
626+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
627+ Decorator::Tab* tab = fTabList.ItemAt(i);
628+ if (tab->closeRect.Contains(where)) {
629+ tabIndex = i;
630+ return REGION_CLOSE_BUTTON;
631+ }
632+ if (tab->zoomRect.Contains(where)) {
633+ tabIndex = i;
634+ return REGION_ZOOM_BUTTON;
635+ }
636+ if (tab->tabRect.Contains(where)) {
637+ tabIndex = i;
638+ return REGION_TAB;
639+ }
640+ }
641+
642+ return REGION_NONE;
643+}
644+
645+
646+/*! \brief Moves the decorator frame and all default rectangles
647+
648+ If a subclass implements this method, be sure to call Decorator::MoveBy
649+ to ensure that internal members are also updated. All members of the
650+ Decorator class are automatically moved in this method
651+
652+ \param x X Offset
653+ \param y y Offset
654+*/
655+void
656+Decorator::MoveBy(float x, float y)
657+{
658+ MoveBy(BPoint(x, y));
659+}
660+
661+
662+/*! \brief Moves the decorator frame and all default rectangles
663+
664+ If a subclass implements this method, be sure to call Decorator::MoveBy
665+ to ensure that internal members are also updated. All members of the
666+ Decorator class are automatically moved in this method
667+
668+ \param offset BPoint containing the offsets
669+*/
670+void
671+Decorator::MoveBy(BPoint offset)
672+{
673+ AutoWriteLocker _(fLocker);
674+
675+ if (fFootprintValid)
676+ fFootprint.OffsetBy(offset.x, offset.y);
677+
678+ _MoveBy(offset);
679+ _MoveOutlineBy(offset);
680+}
681+
682+
683+/*! \brief Resizes the decorator frame
684+
685+ This is a required function for subclasses to implement - the default does
686+ nothing. Note that window resize flags should be followed and fFrame should
687+ be resized accordingly. It would also be a wise idea to ensure that the
688+ window's rectangles are not inverted.
689+
690+ \param x x offset
691+ \param y y offset
692+*/
693+void
694+Decorator::ResizeBy(float x, float y, BRegion* dirty)
695+{
696+ ResizeBy(BPoint(x, y), dirty);
697+}
698+
699+
700+void
701+Decorator::ResizeBy(BPoint offset, BRegion* dirty)
702+{
703+ AutoWriteLocker _(fLocker);
704+
705+ _ResizeBy(offset, dirty);
706+ _ResizeOutlineBy(offset, dirty);
707+
708+ _InvalidateFootprint();
709+}
710+
711+
712+void
713+Decorator::SetOutlinesDelta(BPoint delta, BRegion* dirty)
714+{
715+ _SetOutlinesDelta(delta, dirty);
716+ _InvalidateFootprint();
717+}
718+
719+
720+void
721+Decorator::ExtendDirtyRegion(Region region, BRegion& dirty)
722+{
723+ AutoReadLocker _(fLocker);
724+
725+ switch (region) {
726+ case REGION_TAB:
727+ dirty.Include(fTitleBarRect);
728+ break;
729+
730+ case REGION_CLOSE_BUTTON:
731+ if ((fTopTab->flags & B_NOT_CLOSABLE) == 0) {
732+ for (int32 i = 0; i < fTabList.CountItems(); i++)
733+ dirty.Include(fTabList.ItemAt(i)->closeRect);
734+ }
735+ break;
736+
737+ case REGION_MINIMIZE_BUTTON:
738+ if ((fTopTab->flags & B_NOT_MINIMIZABLE) == 0) {
739+ for (int32 i = 0; i < fTabList.CountItems(); i++)
740+ dirty.Include(fTabList.ItemAt(i)->minimizeRect);
741+ }
742+ break;
743+
744+ case REGION_ZOOM_BUTTON:
745+ if ((fTopTab->flags & B_NOT_ZOOMABLE) == 0) {
746+ for (int32 i = 0; i < fTabList.CountItems(); i++)
747+ dirty.Include(fTabList.ItemAt(i)->zoomRect);
748+ }
749+ break;
750+
751+ case REGION_LEFT_BORDER:
752+ if (fLeftBorder.IsValid()) {
753+ // fLeftBorder doesn't include the corners, so we have to add
754+ // them manually.
755+ BRect rect(fLeftBorder);
756+ rect.top = fTopBorder.top;
757+ rect.bottom = fBottomBorder.bottom;
758+ dirty.Include(rect);
759+ }
760+ break;
761+
762+ case REGION_RIGHT_BORDER:
763+ if (fRightBorder.IsValid()) {
764+ // fRightBorder doesn't include the corners, so we have to add
765+ // them manually.
766+ BRect rect(fRightBorder);
767+ rect.top = fTopBorder.top;
768+ rect.bottom = fBottomBorder.bottom;
769+ dirty.Include(rect);
770+ }
771+ break;
772+
773+ case REGION_TOP_BORDER:
774+ dirty.Include(fTopBorder);
775+ break;
776+
777+ case REGION_BOTTOM_BORDER:
778+ dirty.Include(fBottomBorder);
779+ break;
780+
781+ case REGION_RIGHT_BOTTOM_CORNER:
782+ if ((fTopTab->flags & B_NOT_RESIZABLE) == 0)
783+ dirty.Include(fResizeRect);
784+ break;
785+
786+ default:
787+ break;
788+ }
789+}
790+
791+
792+/*! \brief Sets a specific highlight for a decorator region.
793+
794+ Can be overridden by derived classes, but the base class version must be
795+ called, if the highlight shall be applied.
796+
797+ \param region The decorator region.
798+ \param highlight The value identifying the kind of highlight.
799+ \param dirty The dirty region to be extended, if the highlight changes. Can
800+ be \c NULL.
801+ \return \c true, if the highlight could be applied.
802+*/
803+bool
804+Decorator::SetRegionHighlight(Region region, uint8 highlight, BRegion* dirty,
805+ int32 tab)
806+{
807+ AutoWriteLocker _(fLocker);
808+
809+ int32 index = (int32)region - 1;
810+ if (index < 0 || index >= REGION_COUNT - 1)
811+ return false;
812+
813+ if (fRegionHighlights[index] == highlight)
814+ return true;
815+ fRegionHighlights[index] = highlight;
816+
817+ if (dirty != NULL)
818+ ExtendDirtyRegion(region, *dirty);
819+
820+ return true;
821+}
822+
823+
824+bool
825+Decorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
826+{
827+ AutoWriteLocker _(fLocker);
828+
829+ if (_SetSettings(settings, updateRegion)) {
830+ _InvalidateFootprint();
831+ return true;
832+ }
833+ return false;
834+}
835+
836+
837+bool
838+Decorator::GetSettings(BMessage* settings) const
839+{
840+ AutoReadLocker _(fLocker);
841+
842+ if (!fTitleBarRect.IsValid())
843+ return false;
844+
845+ if (settings->AddRect("tab frame", fTitleBarRect) != B_OK)
846+ return false;
847+
848+ if (settings->AddFloat("border width", fBorderWidth) != B_OK)
849+ return false;
850+
851+ // TODO only add the location of the tab of the window who requested the
852+ // settings
853+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
854+ Decorator::Tab* tab = _TabAt(i);
855+ if (settings->AddFloat("tab location", (float)tab->tabOffset) != B_OK)
856+ return false;
857+ }
858+
859+ return true;
860+}
861+
862+
863+void
864+Decorator::GetSizeLimits(int32* minWidth, int32* minHeight,
865+ int32* maxWidth, int32* maxHeight) const
866+{
867+ AutoReadLocker _(fLocker);
868+
869+ float minTabSize = 0;
870+ if (CountTabs() > 0)
871+ minTabSize = _TabAt(0)->minTabSize;
872+
873+ if (fTitleBarRect.IsValid()) {
874+ *minWidth = (int32)roundf(max_c(*minWidth,
875+ minTabSize - 2 * fBorderWidth));
876+ }
877+ if (fResizeRect.IsValid()) {
878+ *minHeight = (int32)roundf(max_c(*minHeight,
879+ fResizeRect.Height() - fBorderWidth));
880+ }
881+}
882+
883+
884+//! draws the tab, title, and buttons
885+void
886+Decorator::DrawTab(int32 tabIndex)
887+{
888+ AutoReadLocker _(fLocker);
889+
890+ Decorator::Tab* tab = fTabList.ItemAt(tabIndex);
891+ if (tab == NULL)
892+ return;
893+
894+ _DrawTab(tab, tab->tabRect);
895+ _DrawZoom(tab, false, tab->zoomRect);
896+ _DrawMinimize(tab, false, tab->minimizeRect);
897+ _DrawTitle(tab, tab->tabRect);
898+ _DrawClose(tab, false, tab->closeRect);
899+}
900+
901+
902+//! draws the title
903+void
904+Decorator::DrawTitle(int32 tab)
905+{
906+ AutoReadLocker _(fLocker);
907+
908+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
909+ if (decoratorTab == NULL)
910+ return;
911+ _DrawTitle(decoratorTab, decoratorTab->tabRect);
912+}
913+
914+
915+//! Draws the close button
916+void
917+Decorator::DrawClose(int32 tab)
918+{
919+ AutoReadLocker _(fLocker);
920+
921+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
922+ if (decoratorTab == NULL)
923+ return;
924+
925+ _DrawClose(decoratorTab, true, decoratorTab->closeRect);
926+}
927+
928+
929+//! draws the minimize button
930+void
931+Decorator::DrawMinimize(int32 tab)
932+{
933+ AutoReadLocker _(fLocker);
934+
935+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
936+ if (decoratorTab == NULL)
937+ return;
938+
939+ _DrawTab(decoratorTab, decoratorTab->minimizeRect);
940+}
941+
942+
943+//! draws the zoom button
944+void
945+Decorator::DrawZoom(int32 tab)
946+{
947+ AutoReadLocker _(fLocker);
948+
949+ Decorator::Tab* decoratorTab = fTabList.ItemAt(tab);
950+ if (decoratorTab == NULL)
951+ return;
952+ _DrawZoom(decoratorTab, true, decoratorTab->zoomRect);
953+}
954+
955+
956+rgb_color
957+Decorator::UIColor(color_which which)
958+{
959+ AutoReadLocker _(fLocker);
960+ DesktopSettings settings(fDesktop);
961+ return settings.UIColor(which);
962+}
963+
964+
965+float
966+Decorator::BorderWidth()
967+{
968+ AutoReadLocker _(fLocker);
969+ return fBorderWidth;
970+}
971+
972+
973+float
974+Decorator::TabHeight()
975+{
976+ AutoReadLocker _(fLocker);
977+
978+ if (fTitleBarRect.IsValid())
979+ return fTitleBarRect.Height();
980+
981+ return fBorderWidth;
982+}
983+
984+
985+// #pragma mark - Protected methods
986+
987+
988+Decorator::Tab*
989+Decorator::_AllocateNewTab()
990+{
991+ Decorator::Tab* tab = new(std::nothrow) Decorator::Tab;
992+ if (tab == NULL)
993+ return NULL;
994+
995+ // Set appropriate colors based on the current focus value. In this case,
996+ // each decorator defaults to not having the focus.
997+ _SetFocus(tab);
998+ return tab;
999+}
1000+
1001+
1002+void
1003+Decorator::_DrawTabs(BRect rect)
1004+{
1005+ Decorator::Tab* focusTab = NULL;
1006+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
1007+ Decorator::Tab* tab = fTabList.ItemAt(i);
1008+ if (tab->isFocused) {
1009+ focusTab = tab;
1010+ continue;
1011+ }
1012+ _DrawTab(tab, rect);
1013+ }
1014+
1015+ if (focusTab != NULL)
1016+ _DrawTab(focusTab, rect);
1017+}
1018+
1019+
1020+//! Hook function called when the decorator changes focus
1021+void
1022+Decorator::_SetFocus(Decorator::Tab* tab)
1023+{
1024+}
1025+
1026+
1027+bool
1028+Decorator::_SetTabLocation(Decorator::Tab* tab, float location, bool isShifting,
1029+ BRegion* /*updateRegion*/)
1030+{
1031+ return false;
1032+}
1033+
1034+
1035+Decorator::Tab*
1036+Decorator::_TabAt(int32 index) const
1037+{
1038+ return static_cast<Decorator::Tab*>(fTabList.ItemAt(index));
1039+}
1040+
1041+
1042+void
1043+Decorator::_FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
1044+{
1045+ // get previous extent
1046+ if (updateRegion != NULL)
1047+ updateRegion->Include(&GetFootprint());
1048+
1049+ _InvalidateBitmaps();
1050+
1051+ _UpdateFont(settings);
1052+ _DoLayout();
1053+ _DoOutlineLayout();
1054+
1055+ _InvalidateFootprint();
1056+ if (updateRegion != NULL)
1057+ updateRegion->Include(&GetFootprint());
1058+}
1059+
1060+
1061+void
1062+Decorator::_SetLook(Decorator::Tab* tab, DesktopSettings& settings,
1063+ window_look look, BRegion* updateRegion)
1064+{
1065+ // TODO: we could be much smarter about the update region
1066+
1067+ // get previous extent
1068+ if (updateRegion != NULL)
1069+ updateRegion->Include(&GetFootprint());
1070+
1071+ tab->look = look;
1072+
1073+ _UpdateFont(settings);
1074+ _DoLayout();
1075+ _DoOutlineLayout();
1076+
1077+ _InvalidateFootprint();
1078+ if (updateRegion != NULL)
1079+ updateRegion->Include(&GetFootprint());
1080+}
1081+
1082+
1083+void
1084+Decorator::_SetFlags(Decorator::Tab* tab, uint32 flags, BRegion* updateRegion)
1085+{
1086+ // TODO: we could be much smarter about the update region
1087+
1088+ // get previous extent
1089+ if (updateRegion != NULL)
1090+ updateRegion->Include(&GetFootprint());
1091+
1092+ tab->flags = flags;
1093+ _DoLayout();
1094+ _DoOutlineLayout();
1095+
1096+ _InvalidateFootprint();
1097+ if (updateRegion != NULL)
1098+ updateRegion->Include(&GetFootprint());
1099+}
1100+
1101+
1102+void
1103+Decorator::_MoveBy(BPoint offset)
1104+{
1105+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
1106+ Decorator::Tab* tab = fTabList.ItemAt(i);
1107+
1108+ tab->zoomRect.OffsetBy(offset);
1109+ tab->closeRect.OffsetBy(offset);
1110+ tab->minimizeRect.OffsetBy(offset);
1111+ tab->tabRect.OffsetBy(offset);
1112+ }
1113+ fTitleBarRect.OffsetBy(offset);
1114+ fFrame.OffsetBy(offset);
1115+ fResizeRect.OffsetBy(offset);
1116+ fBorderRect.OffsetBy(offset);
1117+}
1118+
1119+
1120+void
1121+Decorator::_MoveOutlineBy(BPoint offset)
1122+{
1123+ fOutlineBorderRect.OffsetBy(offset);
1124+
1125+ fLeftOutlineBorder.OffsetBy(offset);
1126+ fRightOutlineBorder.OffsetBy(offset);
1127+ fTopOutlineBorder.OffsetBy(offset);
1128+ fBottomOutlineBorder.OffsetBy(offset);
1129+}
1130+
1131+
1132+void
1133+Decorator::_ResizeOutlineBy(BPoint offset, BRegion* dirty)
1134+{
1135+ fOutlineBorderRect.right += offset.x;
1136+ fOutlineBorderRect.bottom += offset.y;
1137+
1138+ fLeftOutlineBorder.bottom += offset.y;
1139+ fTopOutlineBorder.right += offset.x;
1140+
1141+ fRightOutlineBorder.OffsetBy(offset.x, 0.0);
1142+ fRightOutlineBorder.bottom += offset.y;
1143+
1144+ fBottomOutlineBorder.OffsetBy(0.0, offset.y);
1145+ fBottomOutlineBorder.right += offset.x;
1146+}
1147+
1148+
1149+void
1150+Decorator::_SetOutlinesDelta(BPoint delta, BRegion* dirty)
1151+{
1152+ BPoint offset = delta - fOutlinesDelta;
1153+ fOutlinesDelta = delta;
1154+
1155+ dirty->Include(fLeftOutlineBorder);
1156+ dirty->Include(fRightOutlineBorder);
1157+ dirty->Include(fTopOutlineBorder);
1158+ dirty->Include(fBottomOutlineBorder);
1159+
1160+ fOutlineBorderRect.right += offset.x;
1161+ fOutlineBorderRect.bottom += offset.y;
1162+
1163+ fLeftOutlineBorder.bottom += offset.y;
1164+ fTopOutlineBorder.right += offset.x;
1165+
1166+ fRightOutlineBorder.OffsetBy(offset.x, 0.0);
1167+ fRightOutlineBorder.bottom += offset.y;
1168+
1169+ fBottomOutlineBorder.OffsetBy(0.0, offset.y);
1170+ fBottomOutlineBorder.right += offset.x;
1171+
1172+ dirty->Include(fLeftOutlineBorder);
1173+ dirty->Include(fRightOutlineBorder);
1174+ dirty->Include(fTopOutlineBorder);
1175+ dirty->Include(fBottomOutlineBorder);
1176+}
1177+
1178+
1179+bool
1180+Decorator::_SetSettings(const BMessage& settings, BRegion* updateRegion)
1181+{
1182+ return false;
1183+}
1184+
1185+
1186+/*! \brief Returns the "footprint" of the entire window, including decorator
1187+
1188+ This function is required by all subclasses.
1189+
1190+ \param region Region to be changed to represent the window's screen
1191+ footprint
1192+*/
1193+void
1194+Decorator::_GetFootprint(BRegion *region)
1195+{
1196+}
1197+
1198+
1199+void
1200+Decorator::_GetOutlineFootprint(BRegion* region)
1201+{
1202+ if (region == NULL)
1203+ return;
1204+
1205+ region->Include(fTopOutlineBorder);
1206+ region->Include(fLeftOutlineBorder);
1207+ region->Include(fRightOutlineBorder);
1208+ region->Include(fBottomOutlineBorder);
1209+}
1210+
1211+
1212+void
1213+Decorator::_InvalidateFootprint()
1214+{
1215+ fFootprintValid = false;
1216+}
1217+
1218+
1219+void
1220+Decorator::_InvalidateBitmaps()
1221+{
1222+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
1223+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_TabAt(i));
1224+ for (int32 index = 0; index < 4; index++) {
1225+ tab->closeBitmaps[index] = NULL;
1226+ tab->minimizeBitmaps[index] = NULL;
1227+ tab->zoomBitmaps[index] = NULL;
1228+ }
1229+ }
1230+}
+335,
-0
1@@ -0,0 +1,335 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * John Scipione, jscipione@gmail.com
10+ * Ingo Weinhold, ingo_weinhold@gmx.de
11+ * Clemens Zeidler, haiku@clemens-zeidler.de
12+ * Joseph Groover, looncraz@looncraz.net
13+ * Tri-Edge AI
14+ * Jacob Secunda, secundja@gmail.com
15+ */
16+#ifndef DECORATOR_H
17+#define DECORATOR_H
18+
19+
20+#include <Rect.h>
21+#include <Region.h>
22+#include <String.h>
23+#include <Window.h>
24+
25+#include "DrawState.h"
26+#include "MultiLocker.h"
27+
28+class Desktop;
29+class DesktopSettings;
30+class DrawingEngine;
31+class ServerBitmap;
32+class ServerFont;
33+class BRegion;
34+
35+
36+class Decorator {
37+public:
38+ struct Tab {
39+ Tab();
40+ virtual ~Tab() {}
41+
42+ BRect tabRect;
43+
44+ BRect zoomRect;
45+ BRect closeRect;
46+ BRect minimizeRect;
47+
48+ bool closePressed : 1;
49+ bool zoomPressed : 1;
50+ bool minimizePressed : 1;
51+
52+ window_look look;
53+ uint32 flags;
54+ bool isFocused : 1;
55+
56+ BString title;
57+
58+ uint32 tabOffset;
59+ float tabLocation;
60+ float textOffset;
61+
62+ BString truncatedTitle;
63+ int32 truncatedTitleLength;
64+
65+ bool buttonFocus : 1;
66+
67+ bool isHighlighted : 1;
68+
69+ float minTabSize;
70+ float maxTabSize;
71+
72+ ServerBitmap* closeBitmaps[4];
73+ ServerBitmap* minimizeBitmaps[4];
74+ ServerBitmap* zoomBitmaps[4];
75+ };
76+
77+ enum Region {
78+ REGION_NONE,
79+
80+ REGION_TAB,
81+
82+ REGION_CLOSE_BUTTON,
83+ REGION_ZOOM_BUTTON,
84+ REGION_MINIMIZE_BUTTON,
85+
86+ REGION_LEFT_BORDER,
87+ REGION_RIGHT_BORDER,
88+ REGION_TOP_BORDER,
89+ REGION_BOTTOM_BORDER,
90+
91+ REGION_LEFT_TOP_CORNER,
92+ REGION_LEFT_BOTTOM_CORNER,
93+ REGION_RIGHT_TOP_CORNER,
94+ REGION_RIGHT_BOTTOM_CORNER,
95+
96+ REGION_COUNT
97+ };
98+
99+ enum {
100+ HIGHLIGHT_NONE,
101+ HIGHLIGHT_RESIZE_BORDER,
102+
103+ HIGHLIGHT_USER_DEFINED
104+ };
105+
106+ Decorator(DesktopSettings& settings,
107+ BRect frame,
108+ Desktop* desktop);
109+ virtual ~Decorator();
110+
111+ virtual Decorator::Tab* AddTab(DesktopSettings& settings,
112+ const char* title, window_look look,
113+ uint32 flags, int32 index = -1,
114+ BRegion* updateRegion = NULL);
115+ virtual bool RemoveTab(int32 index,
116+ BRegion* updateRegion = NULL);
117+ virtual bool MoveTab(int32 from, int32 to, bool isMoving,
118+ BRegion* updateRegion = NULL);
119+
120+ virtual int32 TabAt(const BPoint& where) const;
121+ Decorator::Tab* TabAt(int32 index) const
122+ { return fTabList.ItemAt(index); }
123+ int32 CountTabs() const
124+ { return fTabList.CountItems(); }
125+ void SetTopTab(int32 tab);
126+
127+ void SetDrawingEngine(DrawingEngine *driver);
128+ inline DrawingEngine* GetDrawingEngine() const
129+ { return fDrawingEngine; }
130+
131+ void FontsChanged(DesktopSettings& settings,
132+ BRegion* updateRegion = NULL);
133+ void ColorsChanged(DesktopSettings& settings,
134+ BRegion* updateRegion = NULL);
135+
136+ virtual void UpdateColors(DesktopSettings& settings) = 0;
137+
138+ void SetLook(int32 tab, DesktopSettings& settings,
139+ window_look look,
140+ BRegion* updateRegion = NULL);
141+ void SetFlags(int32 tab, uint32 flags,
142+ BRegion* updateRegion = NULL);
143+
144+ window_look Look(int32 tab) const;
145+ uint32 Flags(int32 tab) const;
146+
147+ BRect BorderRect() const;
148+ BRect TitleBarRect() const;
149+ BRect TabRect(int32 tab) const;
150+ BRect TabRect(Decorator::Tab* tab) const;
151+
152+ void SetClose(int32 tab, bool pressed);
153+ void SetMinimize(int32 tab, bool pressed);
154+ void SetZoom(int32 tab, bool pressed);
155+
156+ const char* Title(int32 tab) const;
157+ const char* Title(Decorator::Tab* tab) const;
158+ void SetTitle(int32 tab, const char* string,
159+ BRegion* updateRegion = NULL);
160+
161+ void SetFocus(int32 tab, bool focussed);
162+ bool IsFocus(int32 tab) const;
163+ bool IsFocus(Decorator::Tab* tab) const;
164+
165+ virtual float TabLocation(int32 tab) const;
166+ bool SetTabLocation(int32 tab, float location,
167+ bool isShifting,
168+ BRegion* updateRegion = NULL);
169+ /*! \return true if tab location updated, false if out of
170+ bounds or unsupported */
171+
172+ virtual Region RegionAt(BPoint where, int32& tab) const;
173+
174+ const BRegion& GetFootprint();
175+ ::Desktop* GetDesktop();
176+
177+ void MoveBy(float x, float y);
178+ void MoveBy(BPoint offset);
179+ void ResizeBy(float x, float y, BRegion* dirty);
180+ void ResizeBy(BPoint offset, BRegion* dirty);
181+ void SetOutlinesDelta(BPoint delta, BRegion* dirty);
182+ bool IsOutlineResizing() const
183+ { return fOutlinesDelta != BPoint(0, 0); }
184+
185+ virtual bool SetRegionHighlight(Region region,
186+ uint8 highlight, BRegion* dirty,
187+ int32 tab = -1);
188+ inline uint8 RegionHighlight(Region region,
189+ int32 tab = -1) const;
190+
191+ bool SetSettings(const BMessage& settings,
192+ BRegion* updateRegion = NULL);
193+ virtual bool GetSettings(BMessage* settings) const;
194+
195+ virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
196+ int32* maxWidth, int32* maxHeight) const;
197+ virtual void ExtendDirtyRegion(Region region, BRegion& dirty);
198+
199+ virtual void Draw(BRect updateRect) = 0;
200+ virtual void Draw() = 0;
201+
202+ virtual void DrawTab(int32 tab);
203+ virtual void DrawTitle(int32 tab);
204+
205+ virtual void DrawClose(int32 tab);
206+ virtual void DrawMinimize(int32 tab);
207+ virtual void DrawZoom(int32 tab);
208+
209+ rgb_color UIColor(color_which which);
210+
211+ float BorderWidth();
212+ float TabHeight();
213+
214+protected:
215+ virtual Decorator::Tab* _AllocateNewTab();
216+
217+ virtual void _DoLayout() = 0;
218+ //! method for calculating layout for the decorator
219+ virtual void _DoOutlineLayout() = 0;
220+
221+ virtual void _DrawFrame(BRect rect) = 0;
222+ virtual void _DrawOutlineFrame(BRect rect) = 0;
223+ virtual void _DrawTabs(BRect rect);
224+
225+ virtual void _DrawTab(Decorator::Tab* tab, BRect rect) = 0;
226+ virtual void _DrawTitle(Decorator::Tab* tab,
227+ BRect rect) = 0;
228+
229+ virtual void _DrawButtons(Decorator::Tab* tab,
230+ const BRect& invalid) = 0;
231+ virtual void _DrawClose(Decorator::Tab* tab, bool direct,
232+ BRect rect) = 0;
233+ virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
234+ BRect rect) = 0;
235+ virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
236+ BRect rect) = 0;
237+
238+ virtual void _SetTitle(Decorator::Tab* tab,
239+ const char* string,
240+ BRegion* updateRegion = NULL) = 0;
241+ int32 _TitleWidth(Decorator::Tab* tab) const
242+ { return tab->title.CountChars(); }
243+
244+ virtual void _SetFocus(Decorator::Tab* tab);
245+ virtual bool _SetTabLocation(Decorator::Tab* tab,
246+ float location, bool isShifting,
247+ BRegion* updateRegion = NULL);
248+
249+ virtual Decorator::Tab* _TabAt(int32 index) const;
250+
251+ virtual void _FontsChanged(DesktopSettings& settings,
252+ BRegion* updateRegion = NULL);
253+ virtual void _UpdateFont(DesktopSettings& settings) = 0;
254+
255+ virtual void _SetLook(Decorator::Tab* tab,
256+ DesktopSettings& settings,
257+ window_look look,
258+ BRegion* updateRegion = NULL);
259+ virtual void _SetFlags(Decorator::Tab* tab, uint32 flags,
260+ BRegion* updateRegion = NULL);
261+
262+ virtual void _MoveBy(BPoint offset);
263+ virtual void _ResizeBy(BPoint offset, BRegion* dirty) = 0;
264+
265+ virtual void _MoveOutlineBy(BPoint offset);
266+ virtual void _ResizeOutlineBy(BPoint offset, BRegion* dirty);
267+ virtual void _SetOutlinesDelta(BPoint delta, BRegion* dirty);
268+
269+ virtual bool _SetSettings(const BMessage& settings,
270+ BRegion* updateRegion = NULL);
271+
272+ virtual bool _AddTab(DesktopSettings& settings,
273+ int32 index = -1,
274+ BRegion* updateRegion = NULL) = 0;
275+ virtual bool _RemoveTab(int32 index,
276+ BRegion* updateRegion = NULL) = 0;
277+ virtual bool _MoveTab(int32 from, int32 to, bool isMoving,
278+ BRegion* updateRegion = NULL) = 0;
279+
280+ virtual void _GetFootprint(BRegion* region);
281+ virtual void _GetOutlineFootprint(BRegion* region);
282+ void _InvalidateFootprint();
283+
284+ void _InvalidateBitmaps();
285+
286+protected:
287+ mutable MultiLocker fLocker;
288+
289+ DrawingEngine* fDrawingEngine;
290+ DrawState fDrawState;
291+
292+ BPoint fOutlinesDelta;
293+
294+ // Individual rects for handling window frame
295+ // rendering the proper way
296+ BRect fTitleBarRect;
297+ BRect fFrame;
298+ BRect fResizeRect;
299+ BRect fBorderRect;
300+ BRect fOutlineBorderRect;
301+
302+ BRect fLeftBorder;
303+ BRect fTopBorder;
304+ BRect fBottomBorder;
305+ BRect fRightBorder;
306+
307+ BRect fLeftOutlineBorder;
308+ BRect fTopOutlineBorder;
309+ BRect fBottomOutlineBorder;
310+ BRect fRightOutlineBorder;
311+
312+ int32 fBorderWidth;
313+ int32 fOutlineBorderWidth;
314+
315+ Decorator::Tab* fTopTab;
316+ BObjectList<Decorator::Tab> fTabList;
317+
318+private:
319+ Desktop* fDesktop;
320+ BRegion fFootprint;
321+ bool fFootprintValid : 1;
322+
323+ uint8 fRegionHighlights[REGION_COUNT - 1];
324+};
325+
326+
327+uint8
328+Decorator::RegionHighlight(Region region, int32 tab) const
329+{
330+ int32 index = (int32)region - 1;
331+ return index >= 0 && index < REGION_COUNT - 1
332+ ? fRegionHighlights[index] : 0;
333+}
334+
335+
336+#endif // DECORATOR_H
+865,
-0
1@@ -0,0 +1,865 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * Ryan Leavengood, leavengood@gmail.com
10+ * Philippe Saint-Pierre, stpere@gmail.com
11+ * John Scipione, jscipione@gmail.com
12+ * Ingo Weinhold, ingo_weinhold@gmx.de
13+ * Clemens Zeidler, haiku@clemens-zeidler.de
14+ * Joseph Groover, looncraz@looncraz.net
15+ * Tri-Edge AI
16+ * Jacob Secunda, secundja@gmail.com
17+ */
18+
19+
20+/*! Default and fallback decorator for the app_server - the yellow tabs */
21+
22+
23+#include "DefaultDecorator.h"
24+
25+#include <algorithm>
26+#include <cmath>
27+#include <new>
28+#include <stdio.h>
29+
30+#include <Autolock.h>
31+#include <Debug.h>
32+#include <GradientLinear.h>
33+#include <Rect.h>
34+#include <Region.h>
35+#include <View.h>
36+
37+#include <WindowPrivate.h>
38+
39+#include "BitmapDrawingEngine.h"
40+#include "DesktopSettings.h"
41+#include "DrawingEngine.h"
42+#include "DrawState.h"
43+#include "FontManager.h"
44+#include "PatternHandler.h"
45+#include "ServerBitmap.h"
46+
47+
48+//#define DEBUG_DECORATOR
49+#ifdef DEBUG_DECORATOR
50+# define STRACE(x) printf x
51+#else
52+# define STRACE(x) ;
53+#endif
54+
55+
56+static const float kBorderResizeLength = 22.0;
57+
58+
59+static inline uint8
60+blend_color_value(uint8 a, uint8 b, float position)
61+{
62+ int16 delta = (int16)b - a;
63+ int32 value = a + (int32)(position * delta);
64+ if (value > 255)
65+ return 255;
66+ if (value < 0)
67+ return 0;
68+
69+ return (uint8)value;
70+}
71+
72+
73+// #pragma mark -
74+
75+
76+// TODO: get rid of DesktopSettings here, and introduce private accessor
77+// methods to the Decorator base class
78+DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
79+ Desktop* desktop)
80+ :
81+ TabDecorator(settings, rect, desktop)
82+{
83+ // TODO: If the decorator was created with a frame too small, it should
84+ // resize itself!
85+
86+ STRACE(("DefaultDecorator:\n"));
87+ STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
88+ rect.left, rect.top, rect.right, rect.bottom));
89+}
90+
91+
92+DefaultDecorator::~DefaultDecorator()
93+{
94+ STRACE(("DefaultDecorator: ~DefaultDecorator()\n"));
95+}
96+
97+
98+// #pragma mark - Public methods
99+
100+
101+/*! Returns the frame colors for the specified decorator component.
102+
103+ The meaning of the color array elements depends on the specified component.
104+ For some components some array elements are unused.
105+
106+ \param component The component for which to return the frame colors.
107+ \param highlight The highlight set for the component.
108+ \param colors An array of colors to be initialized by the function.
109+*/
110+void
111+DefaultDecorator::GetComponentColors(Component component, uint8 highlight,
112+ ComponentColors _colors, Decorator::Tab* _tab)
113+{
114+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
115+ switch (component) {
116+ case COMPONENT_TAB:
117+ if (tab && tab->buttonFocus) {
118+ _colors[COLOR_TAB_FRAME_LIGHT]
119+ = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
120+ _colors[COLOR_TAB_FRAME_DARK]
121+ = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
122+ _colors[COLOR_TAB] = fFocusTabColor;
123+ _colors[COLOR_TAB_LIGHT] = fFocusTabColorLight;
124+ _colors[COLOR_TAB_BEVEL] = fFocusTabColorBevel;
125+ _colors[COLOR_TAB_SHADOW] = fFocusTabColorShadow;
126+ _colors[COLOR_TAB_TEXT] = fFocusTextColor;
127+ } else {
128+ _colors[COLOR_TAB_FRAME_LIGHT]
129+ = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
130+ _colors[COLOR_TAB_FRAME_DARK]
131+ = tint_color(fNonFocusFrameColor, B_DARKEN_3_TINT);
132+ _colors[COLOR_TAB] = fNonFocusTabColor;
133+ _colors[COLOR_TAB_LIGHT] = fNonFocusTabColorLight;
134+ _colors[COLOR_TAB_BEVEL] = fNonFocusTabColorBevel;
135+ _colors[COLOR_TAB_SHADOW] = fNonFocusTabColorShadow;
136+ _colors[COLOR_TAB_TEXT] = fNonFocusTextColor;
137+ }
138+ break;
139+
140+ case COMPONENT_CLOSE_BUTTON:
141+ case COMPONENT_ZOOM_BUTTON:
142+ if (tab && tab->buttonFocus) {
143+ _colors[COLOR_BUTTON] = fFocusTabColor;
144+ _colors[COLOR_BUTTON_LIGHT] = fFocusTabColorLight;
145+ } else {
146+ _colors[COLOR_BUTTON] = fNonFocusTabColor;
147+ _colors[COLOR_BUTTON_LIGHT] = fNonFocusTabColorLight;
148+ }
149+ break;
150+
151+ case COMPONENT_LEFT_BORDER:
152+ case COMPONENT_RIGHT_BORDER:
153+ case COMPONENT_TOP_BORDER:
154+ case COMPONENT_BOTTOM_BORDER:
155+ case COMPONENT_RESIZE_CORNER:
156+ default:
157+ if (tab && tab->buttonFocus) {
158+ _colors[0] = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
159+ _colors[1] = tint_color(fFocusFrameColor, B_LIGHTEN_2_TINT);
160+ _colors[2] = fFocusFrameColor;
161+ _colors[3] = tint_color(fFocusFrameColor,
162+ (B_DARKEN_1_TINT + B_NO_TINT) / 2);
163+ _colors[4] = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
164+ _colors[5] = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
165+ } else {
166+ _colors[0] = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
167+ _colors[1] = tint_color(fNonFocusFrameColor, B_LIGHTEN_2_TINT);
168+ _colors[2] = fNonFocusFrameColor;
169+ _colors[3] = tint_color(fNonFocusFrameColor,
170+ (B_DARKEN_1_TINT + B_NO_TINT) / 2);
171+ _colors[4] = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
172+ _colors[5] = tint_color(fNonFocusFrameColor, B_DARKEN_3_TINT);
173+ }
174+
175+ // for the resize-border highlight dye everything bluish.
176+ if (highlight == HIGHLIGHT_RESIZE_BORDER) {
177+ for (int32 i = 0; i < 6; i++) {
178+ _colors[i].red = std::max((int)_colors[i].red - 80, 0);
179+ _colors[i].green = std::max((int)_colors[i].green - 80, 0);
180+ _colors[i].blue = 255;
181+ }
182+ }
183+ break;
184+ }
185+}
186+
187+
188+void
189+DefaultDecorator::UpdateColors(DesktopSettings& settings)
190+{
191+ TabDecorator::UpdateColors(settings);
192+}
193+
194+
195+// #pragma mark - Protected methods
196+
197+
198+void
199+DefaultDecorator::_DrawFrame(BRect rect)
200+{
201+ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", rect.left, rect.top,
202+ rect.right, rect.bottom));
203+
204+ // NOTE: the DrawingEngine needs to be locked for the entire
205+ // time for the clipping to stay valid for this decorator
206+
207+ if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
208+ return;
209+
210+ if (fBorderWidth <= 0)
211+ return;
212+
213+ // Draw the border frame
214+ BRect border = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
215+ switch ((int)fTopTab->look) {
216+ case B_TITLED_WINDOW_LOOK:
217+ case B_DOCUMENT_WINDOW_LOOK:
218+ case B_MODAL_WINDOW_LOOK:
219+ {
220+ // top
221+ if (rect.Intersects(fTopBorder)) {
222+ ComponentColors colors;
223+ _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
224+
225+ for (int8 i = 0; i < 5; i++) {
226+ fDrawingEngine->StrokeLine(
227+ BPoint(border.left + i, border.top + i),
228+ BPoint(border.right - i, border.top + i), colors[i]);
229+ }
230+ if (fTitleBarRect.IsValid()) {
231+ // grey along the bottom of the tab
232+ // (overwrites "white" from frame)
233+ fDrawingEngine->StrokeLine(
234+ BPoint(fTitleBarRect.left + 2,
235+ fTitleBarRect.bottom + 1),
236+ BPoint(fTitleBarRect.right - 2,
237+ fTitleBarRect.bottom + 1),
238+ colors[2]);
239+ }
240+ }
241+ // left
242+ if (rect.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
243+ ComponentColors colors;
244+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
245+
246+ for (int8 i = 0; i < 5; i++) {
247+ fDrawingEngine->StrokeLine(
248+ BPoint(border.left + i, border.top + i),
249+ BPoint(border.left + i, border.bottom - i), colors[i]);
250+ }
251+ }
252+ // bottom
253+ if (rect.Intersects(fBottomBorder)) {
254+ ComponentColors colors;
255+ _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
256+
257+ for (int8 i = 0; i < 5; i++) {
258+ fDrawingEngine->StrokeLine(
259+ BPoint(border.left + i, border.bottom - i),
260+ BPoint(border.right - i, border.bottom - i),
261+ colors[(4 - i) == 4 ? 5 : (4 - i)]);
262+ }
263+ }
264+ // right
265+ if (rect.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
266+ ComponentColors colors;
267+ _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
268+
269+ for (int8 i = 0; i < 5; i++) {
270+ fDrawingEngine->StrokeLine(
271+ BPoint(border.right - i, border.top + i),
272+ BPoint(border.right - i, border.bottom - i),
273+ colors[(4 - i) == 4 ? 5 : (4 - i)]);
274+ }
275+ }
276+ break;
277+ }
278+
279+ case B_FLOATING_WINDOW_LOOK:
280+ case kLeftTitledWindowLook:
281+ {
282+ // top
283+ if (rect.Intersects(fTopBorder)) {
284+ ComponentColors colors;
285+ _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
286+
287+ for (int8 i = 0; i < 3; i++) {
288+ fDrawingEngine->StrokeLine(
289+ BPoint(border.left + i, border.top + i),
290+ BPoint(border.right - i, border.top + i),
291+ colors[i * 2]);
292+ }
293+ if (fTitleBarRect.IsValid() && fTopTab->look != kLeftTitledWindowLook) {
294+ // grey along the bottom of the tab
295+ // (overwrites "white" from frame)
296+ fDrawingEngine->StrokeLine(
297+ BPoint(fTitleBarRect.left + 2,
298+ fTitleBarRect.bottom + 1),
299+ BPoint(fTitleBarRect.right - 2,
300+ fTitleBarRect.bottom + 1), colors[2]);
301+ }
302+ }
303+ // left
304+ if (rect.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
305+ ComponentColors colors;
306+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
307+
308+ for (int8 i = 0; i < 3; i++) {
309+ fDrawingEngine->StrokeLine(
310+ BPoint(border.left + i, border.top + i),
311+ BPoint(border.left + i, border.bottom - i),
312+ colors[i * 2]);
313+ }
314+ if (fTopTab->look == kLeftTitledWindowLook
315+ && fTitleBarRect.IsValid()) {
316+ // grey along the right side of the tab
317+ // (overwrites "white" from frame)
318+ fDrawingEngine->StrokeLine(
319+ BPoint(fTitleBarRect.right + 1,
320+ fTitleBarRect.top + 2),
321+ BPoint(fTitleBarRect.right + 1,
322+ fTitleBarRect.bottom - 2), colors[2]);
323+ }
324+ }
325+ // bottom
326+ if (rect.Intersects(fBottomBorder)) {
327+ ComponentColors colors;
328+ _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
329+
330+ for (int8 i = 0; i < 3; i++) {
331+ fDrawingEngine->StrokeLine(
332+ BPoint(border.left + i, border.bottom - i),
333+ BPoint(border.right - i, border.bottom - i),
334+ colors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
335+ }
336+ }
337+ // right
338+ if (rect.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
339+ ComponentColors colors;
340+ _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
341+
342+ for (int8 i = 0; i < 3; i++) {
343+ fDrawingEngine->StrokeLine(
344+ BPoint(border.right - i, border.top + i),
345+ BPoint(border.right - i, border.bottom - i),
346+ colors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
347+ }
348+ }
349+ break;
350+ }
351+
352+ case B_BORDERED_WINDOW_LOOK:
353+ {
354+ // TODO: Draw the borders individually!
355+ ComponentColors colors;
356+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
357+
358+ fDrawingEngine->StrokeRect(border, colors[5]);
359+ break;
360+ }
361+
362+ default:
363+ // don't draw a border frame
364+ break;
365+ }
366+
367+ // Draw the resize knob if we're supposed to
368+ if (!(fTopTab->flags & B_NOT_RESIZABLE)) {
369+ ComponentColors colors;
370+ _GetComponentColors(COMPONENT_RESIZE_CORNER, colors, fTopTab);
371+
372+ switch ((int)fTopTab->look) {
373+ case B_DOCUMENT_WINDOW_LOOK:
374+ {
375+ if (fOutlinesDelta.x != 0 || fOutlinesDelta.y != 0) {
376+ border.Set(fFrame.right - 13, fFrame.bottom - 13,
377+ fFrame.right + 3, fFrame.bottom + 3);
378+
379+ if (rect.Intersects(border))
380+ _DrawResizeKnob(border, false, colors);
381+ }
382+
383+ if (rect.Intersects(fResizeRect)) {
384+ _DrawResizeKnob(fResizeRect, fTopTab && IsFocus(fTopTab),
385+ colors);
386+ }
387+
388+ break;
389+ }
390+
391+ case B_TITLED_WINDOW_LOOK:
392+ case B_FLOATING_WINDOW_LOOK:
393+ case B_MODAL_WINDOW_LOOK:
394+ case kLeftTitledWindowLook:
395+ {
396+ if (!rect.Intersects(BRect(
397+ fRightBorder.right - kBorderResizeLength,
398+ fBottomBorder.bottom - kBorderResizeLength,
399+ fRightBorder.right - 1,
400+ fBottomBorder.bottom - 1)))
401+ break;
402+
403+ fDrawingEngine->StrokeLine(
404+ BPoint(fRightBorder.left,
405+ fBottomBorder.bottom - kBorderResizeLength),
406+ BPoint(fRightBorder.right - 1,
407+ fBottomBorder.bottom - kBorderResizeLength),
408+ colors[0]);
409+ fDrawingEngine->StrokeLine(
410+ BPoint(fRightBorder.right - kBorderResizeLength,
411+ fBottomBorder.top),
412+ BPoint(fRightBorder.right - kBorderResizeLength,
413+ fBottomBorder.bottom - 1),
414+ colors[0]);
415+ break;
416+ }
417+
418+ default:
419+ // don't draw resize corner
420+ break;
421+ }
422+ }
423+}
424+
425+
426+void
427+DefaultDecorator::_DrawResizeKnob(BRect rect, bool full,
428+ const ComponentColors& colors)
429+{
430+ float x = rect.right -= 3;
431+ float y = rect.bottom -= 3;
432+
433+ BGradientLinear gradient;
434+ gradient.SetStart(rect.LeftTop());
435+ gradient.SetEnd(rect.RightBottom());
436+ gradient.AddColor(colors[1], 0);
437+ gradient.AddColor(colors[2], 255);
438+
439+ fDrawingEngine->FillRect(rect, gradient);
440+
441+ fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15),
442+ BPoint(x - 15, y - 2), colors[0]);
443+ fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14),
444+ BPoint(x - 14, y - 1), colors[1]);
445+ fDrawingEngine->StrokeLine(BPoint(x - 15, y - 15),
446+ BPoint(x - 2, y - 15), colors[0]);
447+ fDrawingEngine->StrokeLine(BPoint(x - 14, y - 14),
448+ BPoint(x - 1, y - 14), colors[1]);
449+
450+ if (!full)
451+ return;
452+
453+ static const rgb_color kWhite
454+ = (rgb_color){ 255, 255, 255, 255 };
455+ for (int8 i = 1; i <= 4; i++) {
456+ for (int8 j = 1; j <= i; j++) {
457+ BPoint pt1(x - (3 * j) + 1, y - (3 * (5 - i)) + 1);
458+ BPoint pt2(x - (3 * j) + 2, y - (3 * (5 - i)) + 2);
459+ fDrawingEngine->StrokePoint(pt1, colors[0]);
460+ fDrawingEngine->StrokePoint(pt2, kWhite);
461+ }
462+ }
463+}
464+
465+
466+/*! \brief Actually draws the tab
467+
468+ This function is called when the tab itself needs drawn. Other items,
469+ like the window title or buttons, should not be drawn here.
470+
471+ \param tab The \a tab to update.
472+ \param rect The area of the \a tab to update.
473+*/
474+void
475+DefaultDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
476+{
477+ STRACE(("_DrawTab(%.1f,%.1f,%.1f,%.1f)\n",
478+ invalid.left, invalid.top, invalid.right, invalid.bottom));
479+ const BRect& tabRect = tab->tabRect;
480+ // If a window has a tab, this will draw it and any buttons which are
481+ // in it.
482+ if (!tabRect.IsValid() || !invalid.Intersects(tabRect))
483+ return;
484+
485+ ComponentColors colors;
486+ _GetComponentColors(COMPONENT_TAB, colors, tab);
487+
488+ // outer frame
489+ fDrawingEngine->StrokeLine(tabRect.LeftTop(), tabRect.LeftBottom(),
490+ colors[COLOR_TAB_FRAME_LIGHT]);
491+ fDrawingEngine->StrokeLine(tabRect.LeftTop(), tabRect.RightTop(),
492+ colors[COLOR_TAB_FRAME_LIGHT]);
493+ if (tab->look != kLeftTitledWindowLook) {
494+ fDrawingEngine->StrokeLine(tabRect.RightTop(), tabRect.RightBottom(),
495+ colors[COLOR_TAB_FRAME_DARK]);
496+ } else {
497+ fDrawingEngine->StrokeLine(tabRect.LeftBottom(),
498+ tabRect.RightBottom(), colors[COLOR_TAB_FRAME_DARK]);
499+ }
500+
501+ float tabBotton = tabRect.bottom;
502+ if (fTopTab != tab)
503+ tabBotton -= 1;
504+
505+ // bevel
506+ fDrawingEngine->StrokeLine(BPoint(tabRect.left + 1, tabRect.top + 1),
507+ BPoint(tabRect.left + 1,
508+ tabBotton - (tab->look == kLeftTitledWindowLook ? 1 : 0)),
509+ colors[COLOR_TAB_BEVEL]);
510+ fDrawingEngine->StrokeLine(BPoint(tabRect.left + 1, tabRect.top + 1),
511+ BPoint(tabRect.right - (tab->look == kLeftTitledWindowLook ? 0 : 1),
512+ tabRect.top + 1),
513+ colors[COLOR_TAB_BEVEL]);
514+
515+ if (tab->look != kLeftTitledWindowLook) {
516+ fDrawingEngine->StrokeLine(BPoint(tabRect.right - 1, tabRect.top + 2),
517+ BPoint(tabRect.right - 1, tabBotton),
518+ colors[COLOR_TAB_SHADOW]);
519+ } else {
520+ fDrawingEngine->StrokeLine(
521+ BPoint(tabRect.left + 2, tabRect.bottom - 1),
522+ BPoint(tabRect.right, tabRect.bottom - 1),
523+ colors[COLOR_TAB_SHADOW]);
524+ }
525+
526+ // fill
527+ BGradientLinear gradient;
528+ gradient.SetStart(tabRect.LeftTop());
529+ gradient.AddColor(colors[COLOR_TAB_LIGHT], 0);
530+ gradient.AddColor(colors[COLOR_TAB], 255);
531+
532+ if (tab->look != kLeftTitledWindowLook) {
533+ gradient.SetEnd(tabRect.LeftBottom());
534+ fDrawingEngine->FillRect(BRect(tabRect.left + 2, tabRect.top + 2,
535+ tabRect.right - 2, tabBotton), gradient);
536+ } else {
537+ gradient.SetEnd(tabRect.RightTop());
538+ fDrawingEngine->FillRect(BRect(tabRect.left + 2, tabRect.top + 2,
539+ tabRect.right, tabRect.bottom - 2), gradient);
540+ }
541+
542+ _DrawTitle(tab, tabRect);
543+
544+ _DrawButtons(tab, invalid);
545+}
546+
547+
548+/*! \brief Actually draws the title
549+
550+ The main tasks for this function are to ensure that the decorator draws
551+ the title only in its own area and drawing the title itself.
552+ Using B_OP_COPY for drawing the title is recommended because of the marked
553+ performance hit of the other drawing modes, but it is not a requirement.
554+
555+ \param tab The \a tab to update.
556+ \param rect area of the title to update.
557+*/
558+void
559+DefaultDecorator::_DrawTitle(Decorator::Tab* _tab, BRect rect)
560+{
561+ STRACE(("_DrawTitle(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
562+ rect.bottom));
563+
564+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
565+
566+ const BRect& tabRect = tab->tabRect;
567+ const BRect& closeRect = tab->closeRect;
568+ const BRect& zoomRect = tab->zoomRect;
569+
570+ ComponentColors colors;
571+ _GetComponentColors(COMPONENT_TAB, colors, tab);
572+
573+ fDrawingEngine->SetDrawingMode(B_OP_OVER);
574+ fDrawingEngine->SetHighColor(colors[COLOR_TAB_TEXT]);
575+ fDrawingEngine->SetFont(fDrawState.Font());
576+
577+ // figure out position of text
578+ font_height fontHeight;
579+ fDrawState.Font().GetHeight(fontHeight);
580+
581+ BPoint titlePos;
582+ if (tab->look != kLeftTitledWindowLook) {
583+ titlePos.x = closeRect.IsValid() ? closeRect.right + tab->textOffset
584+ : tabRect.left + tab->textOffset;
585+ titlePos.y = floorf(((tabRect.top + 2.0) + tabRect.bottom
586+ + fontHeight.ascent + fontHeight.descent) / 2.0
587+ - fontHeight.descent + 0.5);
588+ } else {
589+ titlePos.x = floorf(((tabRect.left + 2.0) + tabRect.right
590+ + fontHeight.ascent + fontHeight.descent) / 2.0
591+ - fontHeight.descent + 0.5);
592+ titlePos.y = zoomRect.IsValid() ? zoomRect.top - tab->textOffset
593+ : tabRect.bottom - tab->textOffset;
594+ }
595+
596+ fDrawingEngine->DrawString(tab->truncatedTitle, tab->truncatedTitleLength,
597+ titlePos);
598+
599+ fDrawingEngine->SetDrawingMode(B_OP_COPY);
600+}
601+
602+
603+/*! \brief Actually draws the close button
604+
605+ Unless a subclass has a particularly large button, it is probably
606+ unnecessary to check the update rectangle.
607+
608+ \param _tab The \a tab to update.
609+ \param direct Draw without double buffering.
610+ \param rect The area of the button to update.
611+*/
612+void
613+DefaultDecorator::_DrawClose(Decorator::Tab* _tab, bool direct, BRect rect)
614+{
615+ STRACE(("_DrawClose(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
616+ rect.bottom));
617+
618+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
619+
620+ int32 index = (tab->buttonFocus ? 0 : 1) + (tab->closePressed ? 0 : 2);
621+ ServerBitmap* bitmap = tab->closeBitmaps[index];
622+ if (bitmap == NULL) {
623+ bitmap = _GetBitmapForButton(tab, COMPONENT_CLOSE_BUTTON,
624+ tab->closePressed, rect.IntegerWidth(), rect.IntegerHeight());
625+ tab->closeBitmaps[index] = bitmap;
626+ }
627+
628+ _DrawButtonBitmap(bitmap, direct, rect);
629+}
630+
631+
632+/*! \brief Actually draws the zoom button
633+
634+ Unless a subclass has a particularly large button, it is probably
635+ unnecessary to check the update rectangle.
636+
637+ \param _tab The \a tab to update.
638+ \param direct Draw without double buffering.
639+ \param rect The area of the button to update.
640+*/
641+void
642+DefaultDecorator::_DrawZoom(Decorator::Tab* _tab, bool direct, BRect rect)
643+{
644+ STRACE(("_DrawZoom(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
645+ rect.bottom));
646+
647+ if (rect.IntegerWidth() < 1)
648+ return;
649+
650+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
651+ int32 index = (tab->buttonFocus ? 0 : 1) + (tab->zoomPressed ? 0 : 2);
652+ ServerBitmap* bitmap = tab->zoomBitmaps[index];
653+ if (bitmap == NULL) {
654+ bitmap = _GetBitmapForButton(tab, COMPONENT_ZOOM_BUTTON,
655+ tab->zoomPressed, rect.IntegerWidth(), rect.IntegerHeight());
656+ tab->zoomBitmaps[index] = bitmap;
657+ }
658+
659+ _DrawButtonBitmap(bitmap, direct, rect);
660+}
661+
662+
663+void
664+DefaultDecorator::_DrawMinimize(Decorator::Tab* tab, bool direct, BRect rect)
665+{
666+ // This decorator doesn't have this button
667+}
668+
669+
670+// #pragma mark - Private methods
671+
672+
673+void
674+DefaultDecorator::_DrawButtonBitmap(ServerBitmap* bitmap, bool direct,
675+ BRect rect)
676+{
677+ if (bitmap == NULL)
678+ return;
679+
680+ bool copyToFrontEnabled = fDrawingEngine->CopyToFrontEnabled();
681+ fDrawingEngine->SetCopyToFrontEnabled(direct);
682+ drawing_mode oldMode;
683+ fDrawingEngine->SetDrawingMode(B_OP_OVER, oldMode);
684+ fDrawingEngine->DrawBitmap(bitmap, rect.OffsetToCopy(0, 0), rect);
685+ fDrawingEngine->SetDrawingMode(oldMode);
686+ fDrawingEngine->SetCopyToFrontEnabled(copyToFrontEnabled);
687+}
688+
689+
690+/*! \brief Draws a framed rectangle with a gradient.
691+ \param engine The drawing engine to use.
692+ \param rect The rectangular area to draw in.
693+ \param down The rectangle should be drawn recessed or not.
694+ \param colors A button color array of the colors to be used.
695+*/
696+void
697+DefaultDecorator::_DrawBlendedRect(DrawingEngine* engine, const BRect rect,
698+ bool down, const ComponentColors& colors)
699+{
700+ // figure out which colors to use
701+ rgb_color startColor, endColor;
702+ if (down) {
703+ startColor = tint_color(colors[COLOR_BUTTON], B_DARKEN_1_TINT);
704+ endColor = colors[COLOR_BUTTON_LIGHT];
705+ } else {
706+ startColor = tint_color(colors[COLOR_BUTTON], B_LIGHTEN_MAX_TINT);
707+ endColor = colors[COLOR_BUTTON];
708+ }
709+
710+ // fill
711+ BRect fillRect(rect.InsetByCopy(1.0f, 1.0f));
712+
713+ BGradientLinear gradient;
714+ gradient.SetStart(fillRect.LeftTop());
715+ gradient.SetEnd(fillRect.RightBottom());
716+ gradient.AddColor(startColor, 0);
717+ gradient.AddColor(endColor, 255);
718+
719+ engine->FillRect(fillRect, gradient);
720+
721+ // outline
722+ engine->StrokeRect(rect, tint_color(colors[COLOR_BUTTON], B_DARKEN_2_TINT));
723+}
724+
725+
726+ServerBitmap*
727+DefaultDecorator::_GetBitmapForButton(Decorator::Tab* tab, Component item,
728+ bool down, int32 width, int32 height)
729+{
730+ // TODO: the list of shared bitmaps is never freed
731+ struct decorator_bitmap {
732+ Component item;
733+ bool down;
734+ int32 width;
735+ int32 height;
736+ rgb_color baseColor;
737+ rgb_color lightColor;
738+ UtilityBitmap* bitmap;
739+ decorator_bitmap* next;
740+ };
741+
742+ static BLocker sBitmapListLock("decorator lock", true);
743+ static decorator_bitmap* sBitmapList = NULL;
744+
745+ ComponentColors colors;
746+ _GetComponentColors(item, colors, tab);
747+
748+ BAutolock locker(sBitmapListLock);
749+
750+ // search our list for a matching bitmap
751+ // TODO: use a hash map instead?
752+ decorator_bitmap* current = sBitmapList;
753+ while (current) {
754+ if (current->item == item && current->down == down
755+ && current->width == width && current->height == height
756+ && current->baseColor == colors[COLOR_BUTTON]
757+ && current->lightColor == colors[COLOR_BUTTON_LIGHT]) {
758+ return current->bitmap;
759+ }
760+
761+ current = current->next;
762+ }
763+
764+ static BitmapDrawingEngine* sBitmapDrawingEngine = NULL;
765+
766+ // didn't find any bitmap, create a new one
767+ if (sBitmapDrawingEngine == NULL)
768+ sBitmapDrawingEngine = new(std::nothrow) BitmapDrawingEngine();
769+ if (sBitmapDrawingEngine == NULL
770+ || sBitmapDrawingEngine->SetSize(width, height) != B_OK)
771+ return NULL;
772+
773+ BRect rect(0, 0, width - 1, height - 1);
774+
775+ STRACE(("DefaultDecorator creating bitmap for %s %s at size %ldx%ld\n",
776+ item == COMPONENT_CLOSE_BUTTON ? "close" : "zoom",
777+ down ? "down" : "up", width, height));
778+ switch (item) {
779+ case COMPONENT_CLOSE_BUTTON:
780+ _DrawBlendedRect(sBitmapDrawingEngine, rect, down, colors);
781+ break;
782+
783+ case COMPONENT_ZOOM_BUTTON:
784+ {
785+ sBitmapDrawingEngine->FillRect(rect, B_TRANSPARENT_COLOR);
786+ // init the background
787+
788+ float inset = floorf(width / 4.0);
789+ BRect zoomRect(rect);
790+ zoomRect.left += inset;
791+ zoomRect.top += inset;
792+ _DrawBlendedRect(sBitmapDrawingEngine, zoomRect, down, colors);
793+
794+ inset = floorf(width / 2.1);
795+ zoomRect = rect;
796+ zoomRect.right -= inset;
797+ zoomRect.bottom -= inset;
798+ _DrawBlendedRect(sBitmapDrawingEngine, zoomRect, down, colors);
799+ break;
800+ }
801+
802+ default:
803+ break;
804+ }
805+
806+ UtilityBitmap* bitmap = sBitmapDrawingEngine->ExportToBitmap(width, height,
807+ B_RGB32);
808+ if (bitmap == NULL)
809+ return NULL;
810+
811+ // bitmap ready, put it into the list
812+ decorator_bitmap* entry = new(std::nothrow) decorator_bitmap;
813+ if (entry == NULL) {
814+ delete bitmap;
815+ return NULL;
816+ }
817+
818+ entry->item = item;
819+ entry->down = down;
820+ entry->width = width;
821+ entry->height = height;
822+ entry->bitmap = bitmap;
823+ entry->baseColor = colors[COLOR_BUTTON];
824+ entry->lightColor = colors[COLOR_BUTTON_LIGHT];
825+ entry->next = sBitmapList;
826+ sBitmapList = entry;
827+
828+ return bitmap;
829+}
830+
831+
832+void
833+DefaultDecorator::_GetComponentColors(Component component,
834+ ComponentColors _colors, Decorator::Tab* tab)
835+{
836+ // get the highlight for our component
837+ Region region = REGION_NONE;
838+ switch (component) {
839+ case COMPONENT_TAB:
840+ region = REGION_TAB;
841+ break;
842+ case COMPONENT_CLOSE_BUTTON:
843+ region = REGION_CLOSE_BUTTON;
844+ break;
845+ case COMPONENT_ZOOM_BUTTON:
846+ region = REGION_ZOOM_BUTTON;
847+ break;
848+ case COMPONENT_LEFT_BORDER:
849+ region = REGION_LEFT_BORDER;
850+ break;
851+ case COMPONENT_RIGHT_BORDER:
852+ region = REGION_RIGHT_BORDER;
853+ break;
854+ case COMPONENT_TOP_BORDER:
855+ region = REGION_TOP_BORDER;
856+ break;
857+ case COMPONENT_BOTTOM_BORDER:
858+ region = REGION_BOTTOM_BORDER;
859+ break;
860+ case COMPONENT_RESIZE_CORNER:
861+ region = REGION_RIGHT_BOTTOM_CORNER;
862+ break;
863+ }
864+
865+ return GetComponentColors(component, RegionHighlight(region), _colors, tab);
866+}
+70,
-0
1@@ -0,0 +1,70 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * Ryan Leavengood, leavengood@gmail.com
10+ * Philippe Saint-Pierre, stpere@gmail.com
11+ * John Scipione, jscipione@gmail.com
12+ * Ingo Weinhold, ingo_weinhold@gmx.de
13+ * Clemens Zeidler, haiku@clemens-zeidler.de
14+ * Joseph Groover, looncraz@looncraz.net
15+ * Tri-Edge AI
16+ * Jacob Secunda, secundja@gmail.com
17+ */
18+#ifndef DEFAULT_DECORATOR_H
19+#define DEFAULT_DECORATOR_H
20+
21+
22+#include "TabDecorator.h"
23+
24+
25+class Desktop;
26+class ServerBitmap;
27+
28+
29+class DefaultDecorator: public TabDecorator {
30+public:
31+ DefaultDecorator(DesktopSettings& settings,
32+ BRect frame, Desktop* desktop);
33+ virtual ~DefaultDecorator();
34+
35+ virtual void GetComponentColors(Component component,
36+ uint8 highlight, ComponentColors _colors,
37+ Decorator::Tab* tab = NULL);
38+
39+ virtual void UpdateColors(DesktopSettings& settings);
40+
41+protected:
42+ virtual void _DrawFrame(BRect rect);
43+
44+ virtual void _DrawTab(Decorator::Tab* tab, BRect r);
45+ virtual void _DrawTitle(Decorator::Tab* tab, BRect r);
46+ virtual void _DrawClose(Decorator::Tab* tab, bool direct,
47+ BRect rect);
48+ virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
49+ BRect rect);
50+ virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
51+ BRect rect);
52+ virtual void _DrawResizeKnob(BRect r, bool full,
53+ const ComponentColors& color);
54+
55+private:
56+ void _DrawButtonBitmap(ServerBitmap* bitmap,
57+ bool direct, BRect rect);
58+ void _DrawBlendedRect(DrawingEngine *engine,
59+ const BRect rect, bool down,
60+ const ComponentColors& colors);
61+ ServerBitmap* _GetBitmapForButton(Decorator::Tab* tab,
62+ Component item, bool down, int32 width,
63+ int32 height);
64+
65+ void _GetComponentColors(Component component,
66+ ComponentColors _colors,
67+ Decorator::Tab* tab = NULL);
68+};
69+
70+
71+#endif // DEFAULT_DECORATOR_H
+1221,
-0
1@@ -0,0 +1,1221 @@
2+/*
3+ * Copyright 2001-2020, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * DarkWyrm, bpmagic@columbus.rr.com
8+ * Adi Oanca, adioanca@gmail.com
9+ * Stephan Aßmus, superstippi@gmx.de
10+ * Axel Dörfler, axeld@pinc-software.de
11+ * Brecht Machiels, brecht@mos6581.org
12+ * Clemens Zeidler, haiku@clemens-zeidler.de
13+ * Ingo Weinhold, ingo_weinhold@gmx.de
14+ * Tri-Edge AI
15+ * Jacob Secunda, secundja@gmail.com
16+ */
17+
18+
19+#include "DefaultWindowBehaviour.h"
20+
21+#include <math.h>
22+
23+#include <PortLink.h>
24+#include <WindowPrivate.h>
25+
26+#include "AppServer.h"
27+#include "ClickTarget.h"
28+#include "Desktop.h"
29+#include "DefaultDecorator.h"
30+#include "DrawingEngine.h"
31+#include "Window.h"
32+
33+
34+//#define DEBUG_WINDOW_CLICK
35+#ifdef DEBUG_WINDOW_CLICK
36+# define STRACE_CLICK(x) printf x
37+#else
38+# define STRACE_CLICK(x) ;
39+#endif
40+
41+
42+// The span between mouse down
43+static const bigtime_t kWindowActivationTimeout = 500000LL;
44+
45+
46+// #pragma mark - State
47+
48+
49+struct DefaultWindowBehaviour::State {
50+ State(DefaultWindowBehaviour& behavior)
51+ :
52+ fBehavior(behavior),
53+ fWindow(behavior.fWindow),
54+ fDesktop(behavior.fDesktop)
55+ {
56+ }
57+
58+ virtual ~State()
59+ {
60+ }
61+
62+ virtual void EnterState(State* previousState)
63+ {
64+ }
65+
66+ virtual void ExitState(State* nextState)
67+ {
68+ }
69+
70+ virtual bool MouseDown(BMessage* message, BPoint where, bool& _unhandled)
71+ {
72+ return true;
73+ }
74+
75+ virtual void MouseUp(BMessage* message, BPoint where)
76+ {
77+ }
78+
79+ virtual void MouseMoved(BMessage* message, BPoint where, bool isFake)
80+ {
81+ }
82+
83+ virtual void ModifiersChanged(BPoint where, int32 modifiers)
84+ {
85+ }
86+
87+protected:
88+ DefaultWindowBehaviour& fBehavior;
89+ Window* fWindow;
90+ Desktop* fDesktop;
91+};
92+
93+
94+// #pragma mark - MouseTrackingState
95+
96+
97+struct DefaultWindowBehaviour::MouseTrackingState : State {
98+ MouseTrackingState(DefaultWindowBehaviour& behavior, BPoint where,
99+ bool windowActionOnMouseUp, bool minimizeCheckOnMouseUp,
100+ int32 mouseButton = B_PRIMARY_MOUSE_BUTTON)
101+ :
102+ State(behavior),
103+ fMouseButton(mouseButton),
104+ fWindowActionOnMouseUp(windowActionOnMouseUp),
105+ fMinimizeCheckOnMouseUp(minimizeCheckOnMouseUp),
106+ fLastMousePosition(where),
107+ fMouseMoveDistance(0),
108+ fLastMoveTime(system_time())
109+ {
110+ }
111+
112+ virtual void MouseUp(BMessage* message, BPoint where)
113+ {
114+ // ignore, if it's not our mouse button
115+ int32 buttons = message->FindInt32("buttons");
116+ if ((buttons & fMouseButton) != 0)
117+ return;
118+
119+ if (fMinimizeCheckOnMouseUp) {
120+ // If the modifiers haven't changed in the meantime and not too
121+ // much time has elapsed, we're supposed to minimize the window.
122+ fMinimizeCheckOnMouseUp = false;
123+ if (message->FindInt32("modifiers") == fBehavior.fLastModifiers
124+ && (fWindow->Flags() & B_NOT_MINIMIZABLE) == 0
125+ && system_time() - fLastMoveTime < kWindowActivationTimeout) {
126+ fWindow->ServerWindow()->NotifyMinimize(true);
127+ }
128+ }
129+
130+ // Perform the window action in case the mouse was not moved.
131+ if (fWindowActionOnMouseUp) {
132+ // There is a time window for this feature, i.e. click and press
133+ // too long, nothing will happen.
134+ if (system_time() - fLastMoveTime < kWindowActivationTimeout)
135+ MouseUpWindowAction();
136+ }
137+
138+ fBehavior._NextState(NULL);
139+ }
140+
141+ virtual void MouseMoved(BMessage* message, BPoint where, bool isFake)
142+ {
143+ // Limit the rate at which "mouse moved" events are handled that move
144+ // or resize the window. At the moment this affects also tab sliding,
145+ // but 1/75 s is a pretty fine granularity anyway, so don't bother.
146+ bigtime_t now = system_time();
147+ if (now - fLastMoveTime < 13333) {
148+ // TODO: add a "timed event" to query for
149+ // the then current mouse position
150+ return;
151+ }
152+ if (fWindowActionOnMouseUp || fMinimizeCheckOnMouseUp) {
153+ if (now - fLastMoveTime >= kWindowActivationTimeout) {
154+ // This click is too long already for window activation/
155+ // minimizing.
156+ fWindowActionOnMouseUp = false;
157+ fMinimizeCheckOnMouseUp = false;
158+ fLastMoveTime = now;
159+ }
160+ } else
161+ fLastMoveTime = now;
162+
163+ BPoint delta = where - fLastMousePosition;
164+ // NOTE: "delta" is later used to change fLastMousePosition.
165+ // If for some reason no change should take effect, delta
166+ // is to be set to (0, 0) so that fLastMousePosition is not
167+ // adjusted. This way the relative mouse position to the
168+ // item being changed (border during resizing, tab during
169+ // sliding...) stays fixed when the mouse is moved so that
170+ // changes are taking effect again.
171+
172+ // If the window was moved enough, it doesn't come to
173+ // the front in FFM mode when the mouse is released.
174+ if (fWindowActionOnMouseUp || fMinimizeCheckOnMouseUp) {
175+ fMouseMoveDistance += delta.x * delta.x + delta.y * delta.y;
176+ if (fMouseMoveDistance > 16.0f) {
177+ fWindowActionOnMouseUp = false;
178+ fMinimizeCheckOnMouseUp = false;
179+ } else
180+ delta = B_ORIGIN;
181+ }
182+
183+ // perform the action (this also updates the delta)
184+ MouseMovedAction(delta, now);
185+
186+ // set the new mouse position
187+ fLastMousePosition += delta;
188+ }
189+
190+ virtual void MouseMovedAction(BPoint& delta, bigtime_t now)
191+ {
192+ }
193+
194+ virtual void MouseUpWindowAction()
195+ {
196+ // default is window activation
197+ fDesktop->ActivateWindow(fWindow);
198+ }
199+
200+protected:
201+ int32 fMouseButton;
202+ bool fWindowActionOnMouseUp : 1;
203+ bool fMinimizeCheckOnMouseUp : 1;
204+
205+ BPoint fLastMousePosition;
206+ float fMouseMoveDistance;
207+ bigtime_t fLastMoveTime;
208+};
209+
210+
211+// #pragma mark - DragState
212+
213+
214+struct DefaultWindowBehaviour::DragState : MouseTrackingState {
215+ DragState(DefaultWindowBehaviour& behavior, BPoint where,
216+ bool activateOnMouseUp, bool minimizeCheckOnMouseUp)
217+ :
218+ MouseTrackingState(behavior, where, activateOnMouseUp,
219+ minimizeCheckOnMouseUp)
220+ {
221+ }
222+
223+ virtual bool MouseDown(BMessage* message, BPoint where, bool& _unhandled)
224+ {
225+ // right-click while dragging shall bring the window to front
226+ int32 buttons = message->FindInt32("buttons");
227+ if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
228+ if (fWindow == fDesktop->BackWindow())
229+ fDesktop->ActivateWindow(fWindow);
230+ else
231+ fDesktop->SendWindowBehind(fWindow);
232+ return true;
233+ }
234+
235+ return MouseTrackingState::MouseDown(message, where, _unhandled);
236+ }
237+
238+ virtual void MouseMovedAction(BPoint& delta, bigtime_t now)
239+ {
240+ if ((fWindow->Flags() & B_NOT_MOVABLE) == 0) {
241+ BPoint oldLeftTop = fWindow->Frame().LeftTop();
242+
243+ fBehavior.AlterDeltaForSnap(fWindow, delta, now);
244+ fDesktop->MoveWindowBy(fWindow, delta.x, delta.y);
245+
246+ // constrain delta to true change in position
247+ delta = fWindow->Frame().LeftTop() - oldLeftTop;
248+ } else
249+ delta = BPoint(0, 0);
250+ }
251+};
252+
253+
254+// #pragma mark - ResizeState
255+
256+
257+struct DefaultWindowBehaviour::ResizeState : MouseTrackingState {
258+ BPoint fDelta;
259+
260+ ResizeState(DefaultWindowBehaviour& behavior, BPoint where,
261+ bool activateOnMouseUp)
262+ :
263+ MouseTrackingState(behavior, where, activateOnMouseUp, true)
264+ {
265+ fDelta = BPoint(0, 0);
266+ }
267+
268+ virtual void EnterState(State* prevState)
269+ {
270+ }
271+
272+ virtual void ExitState(State* nextState)
273+ {
274+ if ((fWindow->Flags() & B_OUTLINE_RESIZE) != 0) {
275+ fDesktop->SetWindowOutlinesDelta(fWindow, BPoint(0, 0));
276+ fDesktop->ResizeWindowBy(fWindow, fDelta.x, fDelta.y);
277+ }
278+ }
279+
280+ virtual void MouseMovedAction(BPoint& delta, bigtime_t now)
281+ {
282+ if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0) {
283+ if ((fWindow->Flags() & B_NOT_V_RESIZABLE) != 0)
284+ delta.y = 0;
285+ if ((fWindow->Flags() & B_NOT_H_RESIZABLE) != 0)
286+ delta.x = 0;
287+
288+ BPoint oldRightBottom = fWindow->Frame().RightBottom();
289+
290+ if ((fWindow->Flags() & B_OUTLINE_RESIZE) != 0) {
291+ fDelta = delta;
292+ fDesktop->SetWindowOutlinesDelta(fWindow, delta);
293+ } else
294+ fDesktop->ResizeWindowBy(fWindow, delta.x, delta.y);
295+
296+ // constrain delta to true change in size
297+ delta = fWindow->Frame().RightBottom() - oldRightBottom;
298+ } else
299+ delta = BPoint(0, 0);
300+ }
301+};
302+
303+
304+// #pragma mark - SlideTabState
305+
306+
307+struct DefaultWindowBehaviour::SlideTabState : MouseTrackingState {
308+ SlideTabState(DefaultWindowBehaviour& behavior, BPoint where)
309+ :
310+ MouseTrackingState(behavior, where, false, false)
311+ {
312+ }
313+
314+ virtual
315+ ~SlideTabState()
316+ {
317+ fDesktop->SetWindowTabLocation(fWindow, fWindow->TabLocation(), false);
318+ }
319+
320+ virtual void MouseMovedAction(BPoint& delta, bigtime_t now)
321+ {
322+ float location = fWindow->TabLocation();
323+ // TODO: change to [0:1]
324+ location += delta.x;
325+ AdjustMultiTabLocation(location, true);
326+ if (fDesktop->SetWindowTabLocation(fWindow, location, true))
327+ delta.y = 0;
328+ else
329+ delta = BPoint(0, 0);
330+ }
331+
332+ void AdjustMultiTabLocation(float location, bool isShifting)
333+ {
334+ ::Decorator* decorator = fWindow->Decorator();
335+ if (decorator == NULL || decorator->CountTabs() <= 1)
336+ return;
337+
338+ // TODO does not work for none continuous shifts
339+ int32 windowIndex = fWindow->PositionInStack();
340+ DefaultDecorator::Tab* movingTab = static_cast<DefaultDecorator::Tab*>(
341+ decorator->TabAt(windowIndex));
342+ int32 neighbourIndex = windowIndex;
343+ if (movingTab->tabOffset > location)
344+ neighbourIndex--;
345+ else
346+ neighbourIndex++;
347+
348+ DefaultDecorator::Tab* neighbourTab
349+ = static_cast<DefaultDecorator::Tab*>(decorator->TabAt(
350+ neighbourIndex));
351+ if (neighbourTab == NULL)
352+ return;
353+
354+ if (movingTab->tabOffset > location) {
355+ if (location > neighbourTab->tabOffset
356+ + neighbourTab->tabRect.Width() / 2) {
357+ return;
358+ }
359+ } else {
360+ if (location + movingTab->tabRect.Width() < neighbourTab->tabOffset
361+ + neighbourTab->tabRect.Width() / 2) {
362+ return;
363+ }
364+ }
365+
366+ fWindow->MoveToStackPosition(neighbourIndex, isShifting);
367+ }
368+};
369+
370+
371+// #pragma mark - ResizeBorderState
372+
373+
374+struct DefaultWindowBehaviour::ResizeBorderState : MouseTrackingState {
375+ BPoint fDelta;
376+
377+ ResizeBorderState(DefaultWindowBehaviour& behavior, BPoint where,
378+ Decorator::Region region)
379+ :
380+ MouseTrackingState(behavior, where, true, false,
381+ B_SECONDARY_MOUSE_BUTTON),
382+ fHorizontal(NONE),
383+ fVertical(NONE)
384+ {
385+ switch (region) {
386+ case Decorator::REGION_TAB:
387+ // TODO: Handle like the border it is attached to (top/left)?
388+ break;
389+ case Decorator::REGION_LEFT_BORDER:
390+ fHorizontal = LEFT;
391+ break;
392+ case Decorator::REGION_RIGHT_BORDER:
393+ fHorizontal = RIGHT;
394+ break;
395+ case Decorator::REGION_TOP_BORDER:
396+ fVertical = TOP;
397+ break;
398+ case Decorator::REGION_BOTTOM_BORDER:
399+ fVertical = BOTTOM;
400+ break;
401+ case Decorator::REGION_LEFT_TOP_CORNER:
402+ fHorizontal = LEFT;
403+ fVertical = TOP;
404+ break;
405+ case Decorator::REGION_LEFT_BOTTOM_CORNER:
406+ fHorizontal = LEFT;
407+ fVertical = BOTTOM;
408+ break;
409+ case Decorator::REGION_RIGHT_TOP_CORNER:
410+ fHorizontal = RIGHT;
411+ fVertical = TOP;
412+ break;
413+ case Decorator::REGION_RIGHT_BOTTOM_CORNER:
414+ fHorizontal = RIGHT;
415+ fVertical = BOTTOM;
416+ break;
417+ default:
418+ break;
419+ }
420+
421+ fDelta = B_ORIGIN;
422+ }
423+
424+ ResizeBorderState(DefaultWindowBehaviour& behavior, BPoint where,
425+ int8 horizontal, int8 vertical)
426+ :
427+ MouseTrackingState(behavior, where, true, false,
428+ B_SECONDARY_MOUSE_BUTTON),
429+ fHorizontal(horizontal),
430+ fVertical(vertical)
431+ {
432+ fDelta = B_ORIGIN;
433+ }
434+
435+ virtual void EnterState(State* previousState)
436+ {
437+ if ((fWindow->Flags() & B_NOT_RESIZABLE) != 0)
438+ fHorizontal = fVertical = NONE;
439+ else {
440+ if ((fWindow->Flags() & B_NOT_H_RESIZABLE) != 0)
441+ fHorizontal = NONE;
442+
443+ if ((fWindow->Flags() & B_NOT_V_RESIZABLE) != 0)
444+ fVertical = NONE;
445+ }
446+ fBehavior._SetResizeCursor(fHorizontal, fVertical);
447+ }
448+
449+ virtual void ExitState(State* nextState)
450+ {
451+ fBehavior._ResetResizeCursor();
452+
453+ if (fWindow->Flags() & B_OUTLINE_RESIZE) {
454+ fDesktop->SetWindowOutlinesDelta(fWindow, B_ORIGIN);
455+ fDesktop->ResizeWindowBy(fWindow, fDelta.x, fDelta.y);
456+ }
457+ }
458+
459+ virtual void MouseMovedAction(BPoint& delta, bigtime_t now)
460+ {
461+ if (fHorizontal == NONE)
462+ delta.x = 0;
463+ if (fVertical == NONE)
464+ delta.y = 0;
465+
466+ if (delta.x == 0 && delta.y == 0)
467+ return;
468+
469+ // Resize first -- due to the window size limits this is not unlikely
470+ // to turn out differently from what we request.
471+ BPoint oldRightBottom = fWindow->Frame().RightBottom();
472+
473+ if (fWindow->Flags() & B_OUTLINE_RESIZE) {
474+ fDelta = delta;
475+ fDesktop->SetWindowOutlinesDelta(fWindow, BPoint(
476+ delta.x * fHorizontal, delta.y * fVertical));
477+ } else {
478+ fDesktop->ResizeWindowBy(fWindow, delta.x * fHorizontal,
479+ delta.y * fVertical);
480+ }
481+
482+ // constrain delta to true change in size
483+ delta = fWindow->Frame().RightBottom() - oldRightBottom;
484+ delta.x *= fHorizontal;
485+ delta.y *= fVertical;
486+
487+ // see, if we have to move, too
488+ float moveX = fHorizontal == LEFT ? delta.x : 0;
489+ float moveY = fVertical == TOP ? delta.y : 0;
490+
491+ if (moveX != 0 || moveY != 0)
492+ fDesktop->MoveWindowBy(fWindow, moveX, moveY);
493+ }
494+
495+ virtual void MouseUpWindowAction()
496+ {
497+ fDesktop->SendWindowBehind(fWindow);
498+ }
499+
500+private:
501+ int8 fHorizontal;
502+ int8 fVertical;
503+};
504+
505+
506+// #pragma mark - DecoratorButtonState
507+
508+
509+struct DefaultWindowBehaviour::DecoratorButtonState : State {
510+ DecoratorButtonState(DefaultWindowBehaviour& behavior,
511+ int32 tab, Decorator::Region button)
512+ :
513+ State(behavior),
514+ fTab(tab),
515+ fButton(button)
516+ {
517+ }
518+
519+ virtual void EnterState(State* previousState)
520+ {
521+ _RedrawDecorator(NULL);
522+ }
523+
524+ virtual void MouseUp(BMessage* message, BPoint where)
525+ {
526+ // ignore, if it's not the primary mouse button
527+ int32 buttons = message->FindInt32("buttons");
528+ if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0)
529+ return;
530+
531+ // redraw the decorator
532+ if (Decorator* decorator = fWindow->Decorator()) {
533+ BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
534+ fWindow->GetBorderRegion(visibleBorder);
535+ visibleBorder->IntersectWith(&fWindow->VisibleRegion());
536+
537+ DrawingEngine* engine = decorator->GetDrawingEngine();
538+ engine->LockParallelAccess();
539+ engine->ConstrainClippingRegion(visibleBorder);
540+
541+ int32 tab;
542+ switch (fButton) {
543+ case Decorator::REGION_CLOSE_BUTTON:
544+ decorator->SetClose(fTab, false);
545+ if (fBehavior._RegionFor(message, tab) == fButton)
546+ fWindow->ServerWindow()->NotifyQuitRequested();
547+ break;
548+
549+ case Decorator::REGION_ZOOM_BUTTON:
550+ decorator->SetZoom(fTab, false);
551+ if (fBehavior._RegionFor(message, tab) == fButton)
552+ fWindow->ServerWindow()->NotifyZoom();
553+ break;
554+
555+ case Decorator::REGION_MINIMIZE_BUTTON:
556+ decorator->SetMinimize(fTab, false);
557+ if (fBehavior._RegionFor(message, tab) == fButton)
558+ fWindow->ServerWindow()->NotifyMinimize(true);
559+ break;
560+
561+ default:
562+ break;
563+ }
564+
565+ engine->UnlockParallelAccess();
566+
567+ fWindow->RegionPool()->Recycle(visibleBorder);
568+ }
569+
570+ fBehavior._NextState(NULL);
571+ }
572+
573+ virtual void MouseMoved(BMessage* message, BPoint where, bool isFake)
574+ {
575+ _RedrawDecorator(message);
576+ }
577+
578+private:
579+ void _RedrawDecorator(const BMessage* message)
580+ {
581+ if (Decorator* decorator = fWindow->Decorator()) {
582+ BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
583+ fWindow->GetBorderRegion(visibleBorder);
584+ visibleBorder->IntersectWith(&fWindow->VisibleRegion());
585+
586+ DrawingEngine* engine = decorator->GetDrawingEngine();
587+ engine->LockParallelAccess();
588+ engine->ConstrainClippingRegion(visibleBorder);
589+
590+ int32 tab;
591+ Decorator::Region hitRegion = message != NULL
592+ ? fBehavior._RegionFor(message, tab) : fButton;
593+
594+ switch (fButton) {
595+ case Decorator::REGION_CLOSE_BUTTON:
596+ decorator->SetClose(fTab, hitRegion == fButton);
597+ break;
598+
599+ case Decorator::REGION_ZOOM_BUTTON:
600+ decorator->SetZoom(fTab, hitRegion == fButton);
601+ break;
602+
603+ case Decorator::REGION_MINIMIZE_BUTTON:
604+ decorator->SetMinimize(fTab, hitRegion == fButton);
605+ break;
606+
607+ default:
608+ break;
609+ }
610+
611+ engine->UnlockParallelAccess();
612+ fWindow->RegionPool()->Recycle(visibleBorder);
613+ }
614+ }
615+
616+protected:
617+ int32 fTab;
618+ Decorator::Region fButton;
619+};
620+
621+
622+// #pragma mark - ManageWindowState
623+
624+
625+struct DefaultWindowBehaviour::ManageWindowState : State {
626+ ManageWindowState(DefaultWindowBehaviour& behavior, BPoint where)
627+ :
628+ State(behavior),
629+ fLastMousePosition(where),
630+ fHorizontal(NONE),
631+ fVertical(NONE)
632+ {
633+ }
634+
635+ virtual void EnterState(State* previousState)
636+ {
637+ _UpdateBorders(fLastMousePosition);
638+ }
639+
640+ virtual void ExitState(State* nextState)
641+ {
642+ fBehavior._SetBorderHighlights(fHorizontal, fVertical, false);
643+ }
644+
645+ virtual bool MouseDown(BMessage* message, BPoint where, bool& _unhandled)
646+ {
647+ // We're only interested if the secondary mouse button was pressed,
648+ // otherwise let the caller handle the event.
649+ int32 buttons = message->FindInt32("buttons");
650+ if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0) {
651+ _unhandled = true;
652+ return true;
653+ }
654+
655+ fBehavior._NextState(new (std::nothrow) ResizeBorderState(fBehavior,
656+ where, fHorizontal, fVertical));
657+ return true;
658+ }
659+
660+ virtual void MouseMoved(BMessage* message, BPoint where, bool isFake)
661+ {
662+ // If the mouse is still over our window, update the borders. Otherwise
663+ // leave the state.
664+ if (fDesktop->WindowAt(where) == fWindow) {
665+ fLastMousePosition = where;
666+ _UpdateBorders(fLastMousePosition);
667+ } else
668+ fBehavior._NextState(NULL);
669+ }
670+
671+ virtual void ModifiersChanged(BPoint where, int32 modifiers)
672+ {
673+ if (!fBehavior._IsWindowModifier(modifiers))
674+ fBehavior._NextState(NULL);
675+ }
676+
677+private:
678+ void _UpdateBorders(BPoint where)
679+ {
680+ if ((fWindow->Flags() & B_NOT_RESIZABLE) != 0)
681+ return;
682+
683+ // Compute the window center relative location of where. We divide by
684+ // the width respective the height, so we compensate for the window's
685+ // aspect ratio.
686+ BRect frame(fWindow->Frame());
687+ if (frame.Width() + 1 == 0 || frame.Height() + 1 == 0)
688+ return;
689+
690+ float x = (where.x - (frame.left + frame.right) / 2)
691+ / (frame.Width() + 1);
692+ float y = (where.y - (frame.top + frame.bottom) / 2)
693+ / (frame.Height() + 1);
694+
695+ // compute the resize direction
696+ int8 horizontal;
697+ int8 vertical;
698+ _ComputeResizeDirection(x, y, horizontal, vertical);
699+
700+ if ((fWindow->Flags() & B_NOT_H_RESIZABLE) != 0)
701+ horizontal = NONE;
702+ if ((fWindow->Flags() & B_NOT_V_RESIZABLE) != 0)
703+ vertical = NONE;
704+
705+ // update the highlight, if necessary
706+ if (horizontal != fHorizontal || vertical != fVertical) {
707+ fBehavior._SetBorderHighlights(fHorizontal, fVertical, false);
708+ fHorizontal = horizontal;
709+ fVertical = vertical;
710+ fBehavior._SetBorderHighlights(fHorizontal, fVertical, true);
711+ }
712+ }
713+
714+private:
715+ BPoint fLastMousePosition;
716+ int8 fHorizontal;
717+ int8 fVertical;
718+};
719+
720+
721+// #pragma mark - DefaultWindowBehaviour
722+
723+
724+DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
725+ :
726+ fWindow(window),
727+ fDesktop(window->Desktop()),
728+ fLastModifiers(0)
729+{
730+}
731+
732+
733+DefaultWindowBehaviour::~DefaultWindowBehaviour()
734+{
735+}
736+
737+
738+bool
739+DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where,
740+ int32 lastHitRegion, int32& clickCount, int32& _hitRegion)
741+{
742+ fLastModifiers = message->FindInt32("modifiers");
743+ int32 buttons = message->FindInt32("buttons");
744+
745+ int32 numButtons;
746+ if (get_mouse_type(&numButtons) == B_OK) {
747+ switch (numButtons) {
748+ case 1:
749+ // 1 button mouse
750+ if ((fLastModifiers & B_CONTROL_KEY) != 0) {
751+ // emulate right click by holding control
752+ buttons = B_SECONDARY_MOUSE_BUTTON;
753+ message->ReplaceInt32("buttons", buttons);
754+ }
755+ break;
756+
757+ case 2:
758+ // TODO: 2 button mouse, pressing both buttons simultaneously
759+ // emulates middle click
760+
761+ default:
762+ break;
763+ }
764+ }
765+
766+ // if a state is active, let it do the job
767+ if (fState.IsSet()) {
768+ bool unhandled = false;
769+ bool result = fState->MouseDown(message, where, unhandled);
770+ if (!unhandled)
771+ return result;
772+ }
773+
774+ // No state active yet, or it wants us to handle the event -- determine the
775+ // click region and decide what to do.
776+
777+ Decorator* decorator = fWindow->Decorator();
778+
779+ Decorator::Region hitRegion = Decorator::REGION_NONE;
780+ int32 tab = -1;
781+ Action action = ACTION_NONE;
782+
783+ bool inBorderRegion = false;
784+ if (decorator != NULL)
785+ inBorderRegion = decorator->GetFootprint().Contains(where);
786+
787+ bool windowModifier = _IsWindowModifier(fLastModifiers);
788+
789+ if (windowModifier || inBorderRegion) {
790+ // click on the window decorator or we have the window modifier keys
791+ // held
792+
793+ // get the functional hit region
794+ if (windowModifier) {
795+ // click with window modifier keys -- let the whole window behave
796+ // like the border
797+ hitRegion = Decorator::REGION_LEFT_BORDER;
798+ } else {
799+ // click on the decorator -- get the exact region
800+ hitRegion = _RegionFor(message, tab);
801+ }
802+
803+ // translate the region into an action
804+ uint32 flags = fWindow->Flags();
805+
806+ if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0) {
807+ // left mouse button
808+ switch (hitRegion) {
809+ case Decorator::REGION_TAB: {
810+ // tab sliding in any case if either shift key is held down
811+ // except sliding up-down by moving mouse left-right would
812+ // look strange
813+ if ((fLastModifiers & B_SHIFT_KEY) != 0
814+ && fWindow->Look() != kLeftTitledWindowLook) {
815+ action = ACTION_SLIDE_TAB;
816+ break;
817+ }
818+ action = ACTION_DRAG;
819+ break;
820+ }
821+
822+ case Decorator::REGION_LEFT_BORDER:
823+ case Decorator::REGION_RIGHT_BORDER:
824+ case Decorator::REGION_TOP_BORDER:
825+ case Decorator::REGION_BOTTOM_BORDER:
826+ action = ACTION_DRAG;
827+ break;
828+
829+ case Decorator::REGION_CLOSE_BUTTON:
830+ action = (flags & B_NOT_CLOSABLE) == 0
831+ ? ACTION_CLOSE : ACTION_DRAG;
832+ break;
833+
834+ case Decorator::REGION_ZOOM_BUTTON:
835+ action = (flags & B_NOT_ZOOMABLE) == 0
836+ ? ACTION_ZOOM : ACTION_DRAG;
837+ break;
838+
839+ case Decorator::REGION_MINIMIZE_BUTTON:
840+ action = (flags & B_NOT_MINIMIZABLE) == 0
841+ ? ACTION_MINIMIZE : ACTION_DRAG;
842+ break;
843+
844+ case Decorator::REGION_LEFT_TOP_CORNER:
845+ case Decorator::REGION_LEFT_BOTTOM_CORNER:
846+ case Decorator::REGION_RIGHT_TOP_CORNER:
847+ // TODO: Handle correctly!
848+ action = ACTION_DRAG;
849+ break;
850+
851+ case Decorator::REGION_RIGHT_BOTTOM_CORNER:
852+ action = (flags & B_NOT_RESIZABLE) == 0
853+ ? ACTION_RESIZE : ACTION_DRAG;
854+ break;
855+
856+ default:
857+ break;
858+ }
859+ } else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
860+ // right mouse button
861+ switch (hitRegion) {
862+ case Decorator::REGION_TAB:
863+ case Decorator::REGION_LEFT_BORDER:
864+ case Decorator::REGION_RIGHT_BORDER:
865+ case Decorator::REGION_TOP_BORDER:
866+ case Decorator::REGION_BOTTOM_BORDER:
867+ case Decorator::REGION_CLOSE_BUTTON:
868+ case Decorator::REGION_ZOOM_BUTTON:
869+ case Decorator::REGION_MINIMIZE_BUTTON:
870+ case Decorator::REGION_LEFT_TOP_CORNER:
871+ case Decorator::REGION_LEFT_BOTTOM_CORNER:
872+ case Decorator::REGION_RIGHT_TOP_CORNER:
873+ case Decorator::REGION_RIGHT_BOTTOM_CORNER:
874+ action = ACTION_RESIZE_BORDER;
875+ break;
876+
877+ default:
878+ break;
879+ }
880+ }
881+ }
882+
883+ _hitRegion = (int32)hitRegion;
884+
885+ if (action == ACTION_NONE) {
886+ // No action -- if this is a click inside the window's contents,
887+ // let it be forwarded to the window.
888+ return inBorderRegion;
889+ }
890+
891+ // reset the click count, if the hit region differs from the previous one
892+ if (hitRegion != lastHitRegion)
893+ clickCount = 1;
894+
895+ DesktopSettings desktopSettings(fDesktop);
896+ if (!desktopSettings.AcceptFirstClick()) {
897+ // Ignore clicks on decorator buttons if the
898+ // non-floating window doesn't have focus
899+ if (!fWindow->IsFocus() && !fWindow->IsFloating()
900+ && action != ACTION_RESIZE_BORDER
901+ && action != ACTION_RESIZE && action != ACTION_SLIDE_TAB)
902+ action = ACTION_DRAG;
903+ }
904+
905+ bool activateOnMouseUp = false;
906+ if (action != ACTION_RESIZE_BORDER) {
907+ // activate window if in click to activate mode, else only focus it
908+ if (desktopSettings.MouseMode() == B_NORMAL_MOUSE) {
909+ fDesktop->ActivateWindow(fWindow);
910+ } else {
911+ fDesktop->SetFocusWindow(fWindow);
912+ activateOnMouseUp = true;
913+ }
914+ }
915+
916+ // switch to the new state
917+ switch (action) {
918+ case ACTION_CLOSE:
919+ case ACTION_ZOOM:
920+ case ACTION_MINIMIZE:
921+ _NextState(
922+ new (std::nothrow) DecoratorButtonState(*this, tab, hitRegion));
923+ STRACE_CLICK(("===> ACTION_CLOSE/ZOOM/MINIMIZE\n"));
924+ break;
925+
926+ case ACTION_DRAG:
927+ _NextState(new (std::nothrow) DragState(*this, where,
928+ activateOnMouseUp, clickCount == 2));
929+ STRACE_CLICK(("===> ACTION_DRAG\n"));
930+ break;
931+
932+ case ACTION_RESIZE:
933+ _NextState(new (std::nothrow) ResizeState(*this, where,
934+ activateOnMouseUp));
935+ STRACE_CLICK(("===> ACTION_RESIZE\n"));
936+ break;
937+
938+ case ACTION_SLIDE_TAB:
939+ _NextState(new (std::nothrow) SlideTabState(*this, where));
940+ STRACE_CLICK(("===> ACTION_SLIDE_TAB\n"));
941+ break;
942+
943+ case ACTION_RESIZE_BORDER:
944+ _NextState(new (std::nothrow) ResizeBorderState(*this, where,
945+ hitRegion));
946+ STRACE_CLICK(("===> ACTION_RESIZE_BORDER\n"));
947+ break;
948+
949+ default:
950+ break;
951+ }
952+
953+ return true;
954+}
955+
956+
957+void
958+DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
959+{
960+ if (fState.IsSet())
961+ fState->MouseUp(message, where);
962+}
963+
964+
965+void
966+DefaultWindowBehaviour::MouseMoved(BMessage* message, BPoint where, bool isFake)
967+{
968+ if (fState.IsSet()) {
969+ fState->MouseMoved(message, where, isFake);
970+ } else {
971+ // If the window modifiers are hold, enter the window management state.
972+ if (_IsWindowModifier(message->FindInt32("modifiers")))
973+ _NextState(new(std::nothrow) ManageWindowState(*this, where));
974+ }
975+
976+ // change focus in FFM mode
977+ DesktopSettings desktopSettings(fDesktop);
978+ if (desktopSettings.FocusFollowsMouse()
979+ && !fWindow->IsFocus() && (fWindow->Flags() & B_AVOID_FOCUS) == 0) {
980+ // If the mouse move is a fake one, we set the focus to NULL, which
981+ // will cause the window that had focus last to retrieve it again - this
982+ // makes FFM much nicer to use with the keyboard.
983+ fDesktop->SetFocusWindow(isFake ? NULL : fWindow);
984+ }
985+}
986+
987+
988+void
989+DefaultWindowBehaviour::ModifiersChanged(int32 modifiers)
990+{
991+ BPoint where;
992+ int32 buttons;
993+ fDesktop->GetLastMouseState(&where, &buttons);
994+
995+ if (fState.IsSet()) {
996+ fState->ModifiersChanged(where, modifiers);
997+ } else {
998+ // If the window modifiers are hold, enter the window management state.
999+ if (_IsWindowModifier(modifiers))
1000+ _NextState(new(std::nothrow) ManageWindowState(*this, where));
1001+ }
1002+}
1003+
1004+
1005+bool
1006+DefaultWindowBehaviour::AlterDeltaForSnap(Window* window, BPoint& delta,
1007+ bigtime_t now)
1008+{
1009+ return fMagneticBorder.AlterDeltaForSnap(window, delta, now);
1010+}
1011+
1012+
1013+bool
1014+DefaultWindowBehaviour::_IsWindowModifier(int32 modifiers) const
1015+{
1016+ return (fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0
1017+ && (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
1018+ | B_SHIFT_KEY)) == (B_COMMAND_KEY | B_CONTROL_KEY);
1019+}
1020+
1021+
1022+Decorator::Region
1023+DefaultWindowBehaviour::_RegionFor(const BMessage* message, int32& tab) const
1024+{
1025+ Decorator* decorator = fWindow->Decorator();
1026+ if (decorator == NULL)
1027+ return Decorator::REGION_NONE;
1028+
1029+ BPoint where;
1030+ if (message->FindPoint("where", &where) != B_OK)
1031+ return Decorator::REGION_NONE;
1032+
1033+ return decorator->RegionAt(where, tab);
1034+}
1035+
1036+
1037+void
1038+DefaultWindowBehaviour::_SetBorderHighlights(int8 horizontal, int8 vertical,
1039+ bool active)
1040+{
1041+ if (Decorator* decorator = fWindow->Decorator()) {
1042+ uint8 highlight = active
1043+ ? Decorator::HIGHLIGHT_RESIZE_BORDER
1044+ : Decorator::HIGHLIGHT_NONE;
1045+
1046+ // set the highlights for the borders
1047+ BRegion dirtyRegion;
1048+ switch (horizontal) {
1049+ case LEFT:
1050+ decorator->SetRegionHighlight(Decorator::REGION_LEFT_BORDER,
1051+ highlight, &dirtyRegion);
1052+ break;
1053+ case RIGHT:
1054+ decorator->SetRegionHighlight(
1055+ Decorator::REGION_RIGHT_BORDER, highlight,
1056+ &dirtyRegion);
1057+ break;
1058+ }
1059+
1060+ switch (vertical) {
1061+ case TOP:
1062+ decorator->SetRegionHighlight(Decorator::REGION_TOP_BORDER,
1063+ highlight, &dirtyRegion);
1064+ break;
1065+ case BOTTOM:
1066+ decorator->SetRegionHighlight(
1067+ Decorator::REGION_BOTTOM_BORDER, highlight,
1068+ &dirtyRegion);
1069+ break;
1070+ }
1071+
1072+ // set the highlights for the corners
1073+ if (horizontal != NONE && vertical != NONE) {
1074+ if (horizontal == LEFT) {
1075+ if (vertical == TOP) {
1076+ decorator->SetRegionHighlight(
1077+ Decorator::REGION_LEFT_TOP_CORNER, highlight,
1078+ &dirtyRegion);
1079+ } else {
1080+ decorator->SetRegionHighlight(
1081+ Decorator::REGION_LEFT_BOTTOM_CORNER, highlight,
1082+ &dirtyRegion);
1083+ }
1084+ } else {
1085+ if (vertical == TOP) {
1086+ decorator->SetRegionHighlight(
1087+ Decorator::REGION_RIGHT_TOP_CORNER, highlight,
1088+ &dirtyRegion);
1089+ } else {
1090+ decorator->SetRegionHighlight(
1091+ Decorator::REGION_RIGHT_BOTTOM_CORNER, highlight,
1092+ &dirtyRegion);
1093+ }
1094+ }
1095+ }
1096+
1097+ // invalidate the affected regions
1098+ fWindow->ProcessDirtyRegion(dirtyRegion);
1099+ }
1100+}
1101+
1102+
1103+ServerCursor*
1104+DefaultWindowBehaviour::_ResizeCursorFor(int8 horizontal, int8 vertical)
1105+{
1106+ // get the cursor ID corresponding to the border/corner
1107+ BCursorID cursorID = B_CURSOR_ID_SYSTEM_DEFAULT;
1108+
1109+ if (horizontal == LEFT) {
1110+ if (vertical == TOP)
1111+ cursorID = B_CURSOR_ID_RESIZE_NORTH_WEST;
1112+ else if (vertical == BOTTOM)
1113+ cursorID = B_CURSOR_ID_RESIZE_SOUTH_WEST;
1114+ else
1115+ cursorID = B_CURSOR_ID_RESIZE_WEST;
1116+ } else if (horizontal == RIGHT) {
1117+ if (vertical == TOP)
1118+ cursorID = B_CURSOR_ID_RESIZE_NORTH_EAST;
1119+ else if (vertical == BOTTOM)
1120+ cursorID = B_CURSOR_ID_RESIZE_SOUTH_EAST;
1121+ else
1122+ cursorID = B_CURSOR_ID_RESIZE_EAST;
1123+ } else {
1124+ if (vertical == TOP)
1125+ cursorID = B_CURSOR_ID_RESIZE_NORTH;
1126+ else if (vertical == BOTTOM)
1127+ cursorID = B_CURSOR_ID_RESIZE_SOUTH;
1128+ }
1129+
1130+ return fDesktop->GetCursorManager().GetCursor(cursorID);
1131+}
1132+
1133+
1134+void
1135+DefaultWindowBehaviour::_SetResizeCursor(int8 horizontal, int8 vertical)
1136+{
1137+ fDesktop->SetManagementCursor(_ResizeCursorFor(horizontal, vertical));
1138+}
1139+
1140+
1141+void
1142+DefaultWindowBehaviour::_ResetResizeCursor()
1143+{
1144+ fDesktop->SetManagementCursor(NULL);
1145+}
1146+
1147+
1148+/*static*/ void
1149+DefaultWindowBehaviour::_ComputeResizeDirection(float x, float y,
1150+ int8& _horizontal, int8& _vertical)
1151+{
1152+ _horizontal = NONE;
1153+ _vertical = NONE;
1154+
1155+ // compute the angle
1156+ if (x == 0 && y == 0)
1157+ return;
1158+
1159+ float angle = atan2f(y, x);
1160+
1161+ // rotate by 22.5 degree to align our sectors with 45 degree multiples
1162+ angle += M_PI / 8;
1163+
1164+ // add 180 degree to the negative values, so we get a nice 0 to 360
1165+ // degree range
1166+ if (angle < 0)
1167+ angle += M_PI * 2;
1168+
1169+ switch (int(angle / M_PI_4)) {
1170+ case 0:
1171+ _horizontal = RIGHT;
1172+ break;
1173+ case 1:
1174+ _horizontal = RIGHT;
1175+ _vertical = BOTTOM;
1176+ break;
1177+ case 2:
1178+ _vertical = BOTTOM;
1179+ break;
1180+ case 3:
1181+ _horizontal = LEFT;
1182+ _vertical = BOTTOM;
1183+ break;
1184+ case 4:
1185+ _horizontal = LEFT;
1186+ break;
1187+ case 5:
1188+ _horizontal = LEFT;
1189+ _vertical = TOP;
1190+ break;
1191+ case 6:
1192+ _vertical = TOP;
1193+ break;
1194+ case 7:
1195+ default:
1196+ _horizontal = RIGHT;
1197+ _vertical = TOP;
1198+ break;
1199+ }
1200+}
1201+
1202+
1203+void
1204+DefaultWindowBehaviour::_NextState(State* state)
1205+{
1206+ // exit the old state
1207+ if (fState.IsSet())
1208+ fState->ExitState(state);
1209+
1210+ // set and enter the new state
1211+ ObjectDeleter<State> oldState(fState.Detach());
1212+ fState.SetTo(state);
1213+
1214+ if (fState.IsSet()) {
1215+ fState->EnterState(oldState.Get());
1216+ fDesktop->SetMouseEventWindow(fWindow);
1217+ } else if (oldState.IsSet()) {
1218+ // no state anymore -- reset the mouse event window, if it's still us
1219+ if (fDesktop->MouseEventWindow() == fWindow)
1220+ fDesktop->SetMouseEventWindow(NULL);
1221+ }
1222+}
+117,
-0
1@@ -0,0 +1,117 @@
2+/*
3+ * Copyright 2001-2010, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Adi Oanca <adioanca@gmail.com>
9+ * Stephan Aßmus <superstippi@gmx.de>
10+ * Axel Dörfler <axeld@pinc-software.de>
11+ * Brecht Machiels <brecht@mos6581.org>
12+ * Clemens Zeidler <haiku@clemens-zeidler.de>
13+ * Ingo Weinhold <ingo_weinhold@gmx.de>
14+ */
15+#ifndef DEFAULT_WINDOW_BEHAVIOUR_H
16+#define DEFAULT_WINDOW_BEHAVIOUR_H
17+
18+
19+#include "WindowBehaviour.h"
20+
21+#include "Decorator.h"
22+#include "MagneticBorder.h"
23+#include "ServerCursor.h"
24+
25+
26+class Desktop;
27+class Window;
28+
29+
30+class DefaultWindowBehaviour : public WindowBehaviour {
31+public:
32+ DefaultWindowBehaviour(Window* window);
33+ virtual ~DefaultWindowBehaviour();
34+
35+ virtual bool MouseDown(BMessage* message, BPoint where,
36+ int32 lastHitRegion, int32& clickCount,
37+ int32& _hitRegion);
38+ virtual void MouseUp(BMessage* message, BPoint where);
39+ virtual void MouseMoved(BMessage *message, BPoint where,
40+ bool isFake);
41+
42+ virtual void ModifiersChanged(int32 modifiers);
43+
44+protected:
45+ virtual bool AlterDeltaForSnap(Window* window, BPoint& delta,
46+ bigtime_t now);
47+private:
48+ enum Action {
49+ ACTION_NONE,
50+ ACTION_ZOOM,
51+ ACTION_CLOSE,
52+ ACTION_MINIMIZE,
53+ ACTION_TAB,
54+ ACTION_DRAG,
55+ ACTION_SLIDE_TAB,
56+ ACTION_RESIZE,
57+ ACTION_RESIZE_BORDER
58+ };
59+
60+ enum {
61+ // 1 for the "natural" resize border, -1 for the opposite, so
62+ // multiplying the movement delta by that value results in the
63+ // size change.
64+ LEFT = -1,
65+ TOP = -1,
66+ NONE = 0,
67+ RIGHT = 1,
68+ BOTTOM = 1
69+ };
70+
71+ struct State;
72+ struct MouseTrackingState;
73+ struct DragState;
74+ struct ResizeState;
75+ struct SlideTabState;
76+ struct ResizeBorderState;
77+ struct DecoratorButtonState;
78+ struct ManageWindowState;
79+
80+ // to keep gcc 2 happy
81+ friend struct State;
82+ friend struct MouseTrackingState;
83+ friend struct DragState;
84+ friend struct ResizeState;
85+ friend struct SlideTabState;
86+ friend struct ResizeBorderState;
87+ friend struct DecoratorButtonState;
88+ friend struct ManageWindowState;
89+
90+private:
91+ bool _IsWindowModifier(int32 modifiers) const;
92+ Decorator::Region _RegionFor(const BMessage* message,
93+ int32& tab) const;
94+
95+ void _SetBorderHighlights(int8 horizontal,
96+ int8 vertical, bool active);
97+
98+ ServerCursor* _ResizeCursorFor(int8 horizontal,
99+ int8 vertical);
100+ void _SetResizeCursor(int8 horizontal,
101+ int8 vertical);
102+ void _ResetResizeCursor();
103+ static void _ComputeResizeDirection(float x, float y,
104+ int8& _horizontal, int8& _vertical);
105+
106+ void _NextState(State* state);
107+
108+protected:
109+ Window* fWindow;
110+ Desktop* fDesktop;
111+ State* fState;
112+ int32 fLastModifiers;
113+
114+ MagneticBorder fMagneticBorder;
115+};
116+
117+
118+#endif // DEFAULT_WINDOW_BEHAVIOUR_H
+949,
-0
1@@ -0,0 +1,949 @@
2+/*
3+ * Copyright 2009-2013 Haiku, Inc. All rights reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm, bpmagic@columbus.rr.com
8+ * Adrien Destugues, pulkomandy@gmail.com
9+ * John Scipione, jscipione@gmail.com
10+ */
11+
12+
13+/*! Decorator resembling Mac OS 8 and 9 */
14+
15+
16+#include "FlatDecorator.h"
17+
18+#include <new>
19+#include <stdio.h>
20+
21+#include <GradientLinear.h>
22+#include <Point.h>
23+#include <View.h>
24+
25+#include "DesktopSettings.h"
26+#include "DrawingEngine.h"
27+#include "PatternHandler.h"
28+#include "RGBColor.h"
29+
30+
31+//#define DEBUG_DECORATOR
32+#ifdef DEBUG_DECORATOR
33+# define STRACE(x) printf x
34+#else
35+# define STRACE(x) ;
36+#endif
37+
38+
39+MacDecorAddOn::MacDecorAddOn(image_id id, const char* name)
40+ :
41+ DecorAddOn(id, name)
42+{
43+}
44+
45+
46+Decorator*
47+MacDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect,
48+ Desktop* desktop)
49+{
50+ return new (std::nothrow)MacDecorator(settings, rect, desktop);
51+}
52+
53+
54+MacDecorator::MacDecorator(DesktopSettings& settings, BRect frame,
55+ Desktop* desktop)
56+ :
57+ SATDecorator(settings, frame, desktop),
58+ fButtonHighColor((rgb_color) { 232, 232, 232, 255 }),
59+ fButtonLowColor((rgb_color) { 128, 128, 128, 255 }),
60+ fFrameHighColor(settings.UIColor(B_SHINE_COLOR)),
61+ fFrameMidColor(settings.UIColor(B_WINDOW_TAB_COLOR)),
62+ fFrameLowColor(settings.UIColor(B_SHADOW_COLOR)),
63+ fFrameLowerColor((rgb_color) { 0, 0, 0, 255 }),
64+ fFocusTextColor(settings.UIColor(B_WINDOW_TEXT_COLOR)),
65+ fNonFocusTextColor(settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR))
66+{
67+ STRACE(("MacDecorator()\n"));
68+ STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
69+ frame.left, frame.top, frame.right, frame.bottom));
70+}
71+
72+
73+MacDecorator::~MacDecorator()
74+{
75+ STRACE(("~MacDecorator()\n"));
76+}
77+
78+
79+// TODO : Add GetSettings
80+
81+
82+void
83+MacDecorator::Draw(BRect updateRect)
84+{
85+ STRACE(("MacDecorator: Draw(BRect updateRect): "));
86+ updateRect.PrintToStream();
87+
88+ // We need to draw a few things: the tab, the borders,
89+ // and the buttons
90+ fDrawingEngine->SetDrawState(&fDrawState);
91+
92+ _DrawFrame(updateRect & fBorderRect);
93+ _DrawTabs(updateRect & fTitleBarRect);
94+}
95+
96+
97+void
98+MacDecorator::Draw()
99+{
100+ STRACE("MacDecorator::Draw()\n");
101+ fDrawingEngine->SetDrawState(&fDrawState);
102+
103+ _DrawFrame(fBorderRect);
104+ _DrawTabs(fTitleBarRect);
105+}
106+
107+
108+// TODO : add GetSizeLimits
109+
110+
111+Decorator::Region
112+MacDecorator::RegionAt(BPoint where, int32& tab) const
113+{
114+ // Let the base class version identify hits of the buttons and the tab.
115+ Region region = Decorator::RegionAt(where, tab);
116+ if (region != REGION_NONE)
117+ return region;
118+
119+ // check the resize corner
120+ if (/*fTopTab->look == B_DOCUMENT_WINDOW_LOOK && */fResizeRect.Contains(where))
121+ return REGION_RIGHT_BOTTOM_CORNER;
122+
123+ // hit-test the borders
124+ if (!(fTopTab->flags & B_NOT_RESIZABLE)
125+ && (fTopTab->look == B_TITLED_WINDOW_LOOK
126+ || fTopTab->look == B_FLOATING_WINDOW_LOOK
127+ || fTopTab->look == B_MODAL_WINDOW_LOOK)
128+ && fBorderRect.Contains(where) && !fFrame.Contains(where)) {
129+ return REGION_BOTTOM_BORDER;
130+ // TODO: Determine the actual border!
131+ }
132+
133+ return REGION_NONE;
134+}
135+
136+
137+bool
138+MacDecorator::SetRegionHighlight(Region region, uint8 highlight,
139+ BRegion* dirty, int32 tabIndex)
140+{
141+ Decorator::Tab* tab
142+ = static_cast<Decorator::Tab*>(_TabAt(tabIndex));
143+ if (tab != NULL) {
144+ tab->isHighlighted = highlight != 0;
145+ // Invalidate the bitmap caches for the close/minimize/zoom button
146+ // when the highlight changes.
147+ switch (region) {
148+ case REGION_CLOSE_BUTTON:
149+ if (highlight != RegionHighlight(region))
150+ memset(&tab->closeBitmaps, 0, sizeof(tab->closeBitmaps));
151+ break;
152+
153+ case REGION_MINIMIZE_BUTTON:
154+ if (highlight != RegionHighlight(region)) {
155+ memset(&tab->minimizeBitmaps, 0,
156+ sizeof(tab->minimizeBitmaps));
157+ }
158+ break;
159+
160+ case REGION_ZOOM_BUTTON:
161+ if (highlight != RegionHighlight(region))
162+ memset(&tab->zoomBitmaps, 0, sizeof(tab->zoomBitmaps));
163+ break;
164+
165+ default:
166+ break;
167+ }
168+ }
169+
170+ return Decorator::SetRegionHighlight(region, highlight, dirty, tabIndex);
171+}
172+
173+
174+void
175+MacDecorator::_DoLayout()
176+{
177+ STRACE(("MacDecorator: Do Layout\n"));
178+
179+ // Here we determine the size of every rectangle that we use
180+ // internally when we are given the size of the client rectangle.
181+
182+ const int32 kDefaultBorderWidth = 6;
183+
184+ bool hasTab = false;
185+
186+ if (fTopTab) {
187+ switch (fTopTab->look) {
188+ case B_MODAL_WINDOW_LOOK:
189+ fBorderWidth = kDefaultBorderWidth;
190+ break;
191+
192+ case B_TITLED_WINDOW_LOOK:
193+ case B_DOCUMENT_WINDOW_LOOK:
194+ hasTab = true;
195+ fBorderWidth = kDefaultBorderWidth;
196+ break;
197+
198+ case B_FLOATING_WINDOW_LOOK:
199+ hasTab = true;
200+ fBorderWidth = 3;
201+ break;
202+
203+ case B_BORDERED_WINDOW_LOOK:
204+ fBorderWidth = 1;
205+ break;
206+
207+ default:
208+ fBorderWidth = 0;
209+ }
210+ } else
211+ fBorderWidth = 0;
212+
213+ fBorderRect = fFrame.InsetByCopy(-fBorderWidth, -fBorderWidth);
214+
215+ // calculate our tab rect
216+ if (hasTab) {
217+ fBorderRect.top += 3;
218+
219+ font_height fontHeight;
220+ fDrawState.Font().GetHeight(fontHeight);
221+
222+ // TODO the tab is drawn in a fixed height for now
223+ fTitleBarRect.Set(fFrame.left - fBorderWidth,
224+ fFrame.top - 22,
225+ ((fFrame.right - fFrame.left) < 32.0 ?
226+ fFrame.left + 32.0 : fFrame.right) + fBorderWidth,
227+ fFrame.top - 3);
228+
229+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
230+ Decorator::Tab* tab = fTabList.ItemAt(i);
231+
232+ tab->tabRect = fTitleBarRect;
233+ // TODO actually handle multiple tabs
234+
235+ tab->zoomRect = fTitleBarRect;
236+ tab->zoomRect.left = tab->zoomRect.right - 12;
237+ tab->zoomRect.bottom = tab->zoomRect.top + 12;
238+ tab->zoomRect.OffsetBy(-4, 4);
239+
240+ tab->closeRect = tab->zoomRect;
241+ tab->minimizeRect = tab->zoomRect;
242+
243+ tab->closeRect.OffsetTo(fTitleBarRect.left + 4,
244+ fTitleBarRect.top + 4);
245+
246+ tab->zoomRect.OffsetBy(0 - (tab->zoomRect.Width() + 4), 0);
247+ if (Title(tab) != NULL && fDrawingEngine != NULL) {
248+ tab->truncatedTitle = Title(tab);
249+ fDrawingEngine->SetFont(fDrawState.Font());
250+ tab->truncatedTitleLength
251+ = (int32)fDrawingEngine->StringWidth(Title(tab),
252+ strlen(Title(tab)));
253+
254+ if (tab->truncatedTitleLength < (tab->zoomRect.left
255+ - tab->closeRect.right - 10)) {
256+ // start with offset from closerect.right
257+ tab->textOffset = int(((tab->zoomRect.left - 5)
258+ - (tab->closeRect.right + 5)) / 2);
259+ tab->textOffset -= int(tab->truncatedTitleLength / 2);
260+
261+ // now make it the offset from fTabRect.left
262+ tab->textOffset += int(tab->closeRect.right + 5
263+ - fTitleBarRect.left);
264+ } else
265+ tab->textOffset = int(tab->closeRect.right) + 5;
266+ } else
267+ tab->textOffset = 0;
268+ }
269+ } else {
270+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
271+ Decorator::Tab* tab = fTabList.ItemAt(i);
272+
273+ tab->tabRect.Set(0.0, 0.0, -1.0, -1.0);
274+ tab->closeRect.Set(0.0, 0.0, -1.0, -1.0);
275+ tab->zoomRect.Set(0.0, 0.0, -1.0, -1.0);
276+ tab->minimizeRect.Set(0.0, 0.0, -1.0, -1.0);
277+ }
278+ }
279+}
280+
281+
282+void
283+MacDecorator::_DrawFrame(BRect invalid)
284+{
285+ if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
286+ return;
287+
288+ if (fBorderWidth <= 0)
289+ return;
290+
291+ BRect r = fBorderRect;
292+ switch (fTopTab->look) {
293+ case B_TITLED_WINDOW_LOOK:
294+ case B_DOCUMENT_WINDOW_LOOK:
295+ case B_MODAL_WINDOW_LOOK:
296+ {
297+ if (IsFocus(fTopTab)) {
298+ BPoint offset = r.LeftTop();
299+ BPoint pt2 = r.LeftBottom();
300+
301+ // Draw the left side of the frame
302+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
303+ offset.x++;
304+ pt2.x++;
305+ pt2.y--;
306+
307+ fDrawingEngine->StrokeLine(offset, pt2, fFrameHighColor);
308+ offset.x++;
309+ pt2.x++;
310+ pt2.y--;
311+
312+ fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
313+ offset.x++;
314+ pt2.x++;
315+ fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
316+ offset.x++;
317+ pt2.x++;
318+ pt2.y--;
319+
320+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowColor);
321+ offset.x++;
322+ offset.y += 2;
323+ BPoint topleftpt = offset;
324+ pt2.x++;
325+ pt2.y--;
326+
327+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
328+
329+ offset = r.RightTop();
330+ pt2 = r.RightBottom();
331+
332+ // Draw the right side of the frame
333+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
334+ offset.x--;
335+ pt2.x--;
336+
337+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowColor);
338+ offset.x--;
339+ pt2.x--;
340+
341+ fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
342+ offset.x--;
343+ pt2.x--;
344+ fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
345+ offset.x--;
346+ pt2.x--;
347+
348+ fDrawingEngine->StrokeLine(offset, pt2, fFrameHighColor);
349+ offset.x--;
350+ offset.y += 2;
351+ BPoint toprightpt = offset;
352+ pt2.x--;
353+
354+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
355+
356+ // Draw the top side of the frame that is not in the tab
357+ if (fTopTab->look == B_MODAL_WINDOW_LOOK) {
358+ offset = r.LeftTop();
359+ pt2 = r.RightTop();
360+
361+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
362+ offset.x++;
363+ offset.y++;
364+ pt2.x--;
365+ pt2.y++;
366+
367+ fDrawingEngine->StrokeLine(offset, pt2, fFrameHighColor);
368+ offset.x++;
369+ offset.y++;
370+ pt2.x--;
371+ pt2.y++;
372+
373+ fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
374+ offset.x++;
375+ offset.y++;
376+ pt2.x--;
377+ pt2.y++;
378+
379+ fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
380+ offset.x++;
381+ offset.y++;
382+ pt2.x--;
383+ pt2.y++;
384+
385+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowColor);
386+ offset.x++;
387+ offset.y++;
388+ pt2.x--;
389+ pt2.y++;
390+
391+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
392+ } else {
393+ // Some odd stuff here where the title bar is melded into the
394+ // window border so that the sides are drawn into the title
395+ // so we draw this bottom up
396+ offset = topleftpt;
397+ pt2 = toprightpt;
398+
399+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
400+ offset.y--;
401+ offset.x++;
402+ pt2.y--;
403+
404+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowColor);
405+ }
406+
407+ // Draw the bottom side of the frame
408+ offset = r.LeftBottom();
409+ pt2 = r.RightBottom();
410+
411+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
412+ offset.x++;
413+ offset.y--;
414+ pt2.x--;
415+ pt2.y--;
416+
417+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowColor);
418+ offset.x++;
419+ offset.y--;
420+ pt2.x--;
421+ pt2.y--;
422+
423+ fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
424+ offset.x++;
425+ offset.y--;
426+ pt2.x--;
427+ pt2.y--;
428+
429+ fDrawingEngine->StrokeLine(offset, pt2, fFrameMidColor);
430+ offset.x++;
431+ offset.y--;
432+ pt2.x--;
433+ pt2.y--;
434+
435+ fDrawingEngine->StrokeLine(offset, pt2, fFrameHighColor);
436+ offset.x += 2;
437+ offset.y--;
438+ pt2.x--;
439+ pt2.y--;
440+
441+ fDrawingEngine->StrokeLine(offset, pt2, fFrameLowerColor);
442+ offset.y--;
443+ pt2.x--;
444+ pt2.y--;
445+ } else {
446+ r.top -= 3;
447+ RGBColor inactive(82, 82, 82);
448+
449+ fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(),
450+ inactive);
451+ fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(),
452+ inactive);
453+ fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(),
454+ inactive);
455+
456+ for (int i = 0; i < 4; i++) {
457+ r.InsetBy(1, 1);
458+ fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(),
459+ fFrameMidColor);
460+ fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(),
461+ fFrameMidColor);
462+ fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(),
463+ fFrameMidColor);
464+ fDrawingEngine->StrokeLine(r.LeftTop(), r.RightTop(),
465+ fFrameMidColor);
466+ }
467+
468+ r.InsetBy(1, 1);
469+ fDrawingEngine->StrokeLine(r.LeftTop(), r.LeftBottom(),
470+ inactive);
471+ fDrawingEngine->StrokeLine(r.RightTop(), r.RightBottom(),
472+ inactive);
473+ fDrawingEngine->StrokeLine(r.LeftBottom(), r.RightBottom(),
474+ inactive);
475+ fDrawingEngine->StrokeLine(r.LeftTop(), r.RightTop(),
476+ inactive);
477+ }
478+ break;
479+ }
480+ case B_BORDERED_WINDOW_LOOK:
481+ fDrawingEngine->StrokeRect(r, fFrameMidColor);
482+ break;
483+
484+ default:
485+ // don't draw a border frame
486+ break;
487+ }
488+}
489+
490+
491+void
492+MacDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
493+{
494+ // If a window has a tab, this will draw it and any buttons which are
495+ // in it.
496+ if (!tab->tabRect.IsValid() || !invalid.Intersects(tab->tabRect))
497+ return;
498+
499+ BRect rect(tab->tabRect);
500+ fDrawingEngine->SetHighColor(RGBColor(fFrameMidColor));
501+ fDrawingEngine->FillRect(rect, fFrameMidColor);
502+
503+ if (IsFocus(tab)) {
504+ fDrawingEngine->StrokeLine(rect.LeftTop(), rect.RightTop(),
505+ fFrameLowerColor);
506+ fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom(),
507+ fFrameLowerColor);
508+ fDrawingEngine->StrokeLine(rect.RightBottom(), rect.RightTop(),
509+ fFrameLowerColor);
510+
511+ rect.InsetBy(1, 1);
512+ rect.bottom++;
513+
514+ fDrawingEngine->StrokeLine(rect.LeftTop(), rect.RightTop(),
515+ fFrameHighColor);
516+ fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom(),
517+ fFrameHighColor);
518+ fDrawingEngine->StrokeLine(rect.RightBottom(), rect.RightTop(),
519+ fFrameLowColor);
520+
521+ // Draw the neat little lines on either side of the title if there's
522+ // room
523+ float left;
524+ if ((tab->flags & B_NOT_CLOSABLE) == 0)
525+ left = tab->closeRect.right;
526+ else
527+ left = tab->tabRect.left;
528+
529+ float right;
530+ if ((tab->flags & B_NOT_ZOOMABLE) == 0)
531+ right = tab->zoomRect.left;
532+ else if ((tab->flags & B_NOT_MINIMIZABLE) == 0)
533+ right = tab->minimizeRect.left;
534+ else
535+ right = tab->tabRect.right;
536+
537+ if (tab->tabRect.left + tab->textOffset > left + 5) {
538+ RGBColor dark(115, 115, 115);
539+
540+ // Left side
541+
542+ BPoint offset(left + 5, tab->closeRect.top);
543+ BPoint pt2(tab->tabRect.left + tab->textOffset - 5,
544+ tab->closeRect.top);
545+
546+ fDrawState.SetHighColor(RGBColor(fFrameHighColor));
547+ for (int32 i = 0; i < 6; i++) {
548+ fDrawingEngine->StrokeLine(offset, pt2,
549+ fDrawState.HighColor());
550+ offset.y += 2;
551+ pt2.y += 2;
552+ }
553+
554+ offset.Set(left + 6, tab->closeRect.top + 1);
555+ pt2.Set(tab->tabRect.left + tab->textOffset - 4,
556+ tab->closeRect.top + 1);
557+
558+ fDrawState.SetHighColor(dark);
559+ for (int32 i = 0; i < 6; i++) {
560+ fDrawingEngine->StrokeLine(offset, pt2,
561+ fDrawState.HighColor());
562+ offset.y += 2;
563+ pt2.y += 2;
564+ }
565+
566+ // Right side
567+
568+ offset.Set(tab->tabRect.left + tab->textOffset
569+ + tab->truncatedTitleLength + 3, tab->zoomRect.top);
570+ pt2.Set(right - 8, tab->zoomRect.top);
571+
572+ if (offset.x < pt2.x) {
573+ fDrawState.SetHighColor(RGBColor(fFrameHighColor));
574+ for (int32 i = 0; i < 6; i++) {
575+ fDrawingEngine->StrokeLine(offset, pt2,
576+ fDrawState.HighColor());
577+ offset.y += 2;
578+ pt2.y += 2;
579+ }
580+
581+ offset.Set(tab->tabRect.left + tab->textOffset
582+ + tab->truncatedTitleLength + 4, tab->zoomRect.top + 1);
583+ pt2.Set(right - 7, tab->zoomRect.top + 1);
584+
585+ fDrawState.SetHighColor(dark);
586+ for(int32 i = 0; i < 6; i++) {
587+ fDrawingEngine->StrokeLine(offset, pt2,
588+ fDrawState.HighColor());
589+ offset.y += 2;
590+ pt2.y += 2;
591+ }
592+ }
593+ }
594+
595+ _DrawButtons(tab, rect);
596+ } else {
597+ RGBColor inactive(82, 82, 82);
598+ // Not focused - Just draw a plain light grey area with the title
599+ // in the middle
600+ fDrawingEngine->StrokeLine(rect.LeftTop(), rect.RightTop(),
601+ inactive);
602+ fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftBottom(),
603+ inactive);
604+ fDrawingEngine->StrokeLine(rect.RightBottom(), rect.RightTop(),
605+ inactive);
606+ }
607+
608+ _DrawTitle(tab, tab->tabRect);
609+}
610+
611+
612+void
613+MacDecorator::_DrawButtons(Decorator::Tab* tab, const BRect& invalid)
614+{
615+ if ((tab->flags & B_NOT_CLOSABLE) == 0
616+ && invalid.Intersects(tab->closeRect)) {
617+ _DrawClose(tab, false, tab->closeRect);
618+ }
619+ if ((tab->flags & B_NOT_MINIMIZABLE) == 0
620+ && invalid.Intersects(tab->minimizeRect)) {
621+ _DrawMinimize(tab, false, tab->minimizeRect);
622+ }
623+ if ((tab->flags & B_NOT_ZOOMABLE) == 0
624+ && invalid.Intersects(tab->zoomRect)) {
625+ _DrawZoom(tab, false, tab->zoomRect);
626+ }
627+}
628+
629+
630+void
631+MacDecorator::_DrawTitle(Decorator::Tab* tab, BRect rect)
632+{
633+ fDrawingEngine->SetHighColor(IsFocus(tab)
634+ ? fFocusTextColor : fNonFocusTextColor);
635+
636+ fDrawingEngine->SetLowColor(fFrameMidColor);
637+
638+ tab->truncatedTitle = Title(tab);
639+ fDrawState.Font().TruncateString(&tab->truncatedTitle, B_TRUNCATE_END,
640+ (tab->zoomRect.left - 5) - (tab->closeRect.right + 5));
641+ fDrawingEngine->SetFont(fDrawState.Font());
642+
643+ fDrawingEngine->DrawString(tab->truncatedTitle, tab->truncatedTitle.Length(),
644+ BPoint(fTitleBarRect.left + tab->textOffset,
645+ tab->closeRect.bottom - 1));
646+}
647+
648+
649+void
650+MacDecorator::_DrawClose(Decorator::Tab* tab, bool direct, BRect r)
651+{
652+ _DrawButton(tab, direct, r, tab->closePressed);
653+}
654+
655+
656+void
657+MacDecorator::_DrawZoom(Decorator::Tab* tab, bool direct, BRect rect)
658+{
659+ _DrawButton(tab, direct, rect, tab->zoomPressed);
660+
661+ rect.top++;
662+ rect.left++;
663+ rect.bottom = rect.top + 6;
664+ rect.right = rect.left + 6;
665+
666+ fDrawState.SetHighColor(RGBColor(33, 33, 33));
667+ fDrawingEngine->StrokeRect(rect, fDrawState.HighColor());
668+}
669+
670+
671+void
672+MacDecorator::_DrawMinimize(Decorator::Tab* tab, bool direct, BRect rect)
673+{
674+ _DrawButton(tab, direct, rect, tab->minimizePressed);
675+
676+ rect.InsetBy(1, 5);
677+
678+ fDrawState.SetHighColor(RGBColor(33, 33, 33));
679+ fDrawingEngine->StrokeRect(rect, fDrawState.HighColor());
680+}
681+
682+
683+void
684+MacDecorator::_SetTitle(Tab* tab, const char* string, BRegion* updateRegion)
685+{
686+ // TODO: we could be much smarter about the update region
687+ // TODO may this change the other tabs too ? (to make space for a longer
688+ // title ?)
689+
690+ BRect rect = TabRect(tab);
691+
692+ _DoLayout();
693+
694+ if (updateRegion == NULL)
695+ return;
696+
697+ rect = rect | TabRect(tab);
698+
699+ rect.bottom++;
700+ // the border will look differently when the title is adjacent
701+
702+ updateRegion->Include(rect);
703+}
704+
705+
706+// TODO : _SetFocus
707+
708+
709+void
710+MacDecorator::_MoveBy(BPoint offset)
711+{
712+ // Move all internal rectangles the appropriate amount
713+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
714+ Decorator::Tab* tab = fTabList.ItemAt(i);
715+ tab->zoomRect.OffsetBy(offset);
716+ tab->minimizeRect.OffsetBy(offset);
717+ tab->closeRect.OffsetBy(offset);
718+ tab->tabRect.OffsetBy(offset);
719+ }
720+
721+ fFrame.OffsetBy(offset);
722+ fTitleBarRect.OffsetBy(offset);
723+ fResizeRect.OffsetBy(offset);
724+ fBorderRect.OffsetBy(offset);
725+}
726+
727+
728+void
729+MacDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
730+{
731+ // Move all internal rectangles the appropriate amount
732+ fFrame.right += offset.x;
733+ fFrame.bottom += offset.y;
734+
735+ fTitleBarRect.right += offset.x;
736+ fBorderRect.right += offset.x;
737+ fBorderRect.bottom += offset.y;
738+ // fZoomRect.OffsetBy(offset.x, 0);
739+ // fMinimizeRect.OffsetBy(offset.x, 0);
740+ if (dirty) {
741+ dirty->Include(fTitleBarRect);
742+ dirty->Include(fBorderRect);
743+ }
744+
745+ // TODO probably some other layouting stuff here
746+ _DoLayout();
747+}
748+
749+
750+// TODO : _SetSettings
751+
752+
753+Decorator::Tab*
754+MacDecorator::_AllocateNewTab()
755+{
756+ Decorator::Tab* tab = new(std::nothrow) Decorator::Tab;
757+ if (tab == NULL)
758+ return NULL;
759+
760+ // Set appropriate colors based on the current focus value. In this case,
761+ // each decorator defaults to not having the focus.
762+ _SetFocus(tab);
763+ return tab;
764+}
765+
766+
767+bool
768+MacDecorator::_AddTab(DesktopSettings& settings, int32 index,
769+ BRegion* updateRegion)
770+{
771+ _UpdateFont(settings);
772+
773+ _DoLayout();
774+ if (updateRegion != NULL)
775+ updateRegion->Include(fTitleBarRect);
776+ return true;
777+}
778+
779+
780+bool
781+MacDecorator::_RemoveTab(int32 index, BRegion* updateRegion)
782+{
783+ BRect oldTitle = fTitleBarRect;
784+ _DoLayout();
785+ if (updateRegion != NULL) {
786+ updateRegion->Include(oldTitle);
787+ updateRegion->Include(fTitleBarRect);
788+ }
789+ return true;
790+}
791+
792+
793+bool
794+MacDecorator::_MoveTab(int32 from, int32 to, bool isMoving,
795+ BRegion* updateRegion)
796+{
797+ return false;
798+
799+#if 0
800+ MacDecorator::Tab* toTab = _TabAt(to);
801+ if (toTab == NULL)
802+ return false;
803+
804+ if (from < to) {
805+ fOldMovingTab.OffsetBy(toTab->tabRect.Width(), 0);
806+ toTab->tabRect.OffsetBy(-fOldMovingTab.Width(), 0);
807+ } else {
808+ fOldMovingTab.OffsetBy(-toTab->tabRect.Width(), 0);
809+ toTab->tabRect.OffsetBy(fOldMovingTab.Width(), 0);
810+ }
811+
812+ toTab->tabOffset = uint32(toTab->tabRect.left - fLeftBorder.left);
813+ _LayoutTabItems(toTab, toTab->tabRect);
814+
815+ _CalculateTabsRegion();
816+
817+ if (updateRegion != NULL)
818+ updateRegion->Include(fTitleBarRect);
819+ return true;
820+#endif
821+}
822+
823+
824+void
825+MacDecorator::_GetFootprint(BRegion* region)
826+{
827+ // This function calculates the decorator's footprint in coordinates
828+ // relative to the view. This is most often used to set a Window
829+ // object's visible region.
830+ if (!region)
831+ return;
832+
833+ region->MakeEmpty();
834+
835+ if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
836+ return;
837+
838+ region->Set(fBorderRect);
839+ region->Exclude(fFrame);
840+
841+ if (fTopTab->look == B_BORDERED_WINDOW_LOOK)
842+ return;
843+ region->Include(fTitleBarRect);
844+}
845+
846+
847+void
848+MacDecorator::_UpdateFont(DesktopSettings& settings)
849+{
850+ ServerFont font;
851+ if (fTopTab && fTopTab->look == B_FLOATING_WINDOW_LOOK)
852+ settings.GetDefaultPlainFont(font);
853+ else
854+ settings.GetDefaultBoldFont(font);
855+
856+ font.SetFlags(B_FORCE_ANTIALIASING);
857+ font.SetSpacing(B_STRING_SPACING);
858+ fDrawState.SetFont(font);
859+}
860+
861+
862+// #pragma mark - Private methods
863+
864+
865+// Draw a mac-style button
866+void
867+MacDecorator::_DrawButton(Decorator::Tab* tab, bool direct, BRect r,
868+ bool down)
869+{
870+ BRect rect(r);
871+
872+ BPoint offset(r.LeftTop()), pt2(r.RightTop());
873+
874+ // Topleft dark grey border
875+ pt2.x--;
876+ fDrawingEngine->SetHighColor(RGBColor(136, 136, 136));
877+ fDrawingEngine->StrokeLine(offset, pt2);
878+
879+ pt2 = r.LeftBottom();
880+ pt2.y--;
881+ fDrawingEngine->StrokeLine(offset, pt2);
882+
883+ // Bottomright white border
884+ offset = r.RightBottom();
885+ pt2 = r.RightTop();
886+ pt2.y++;
887+ fDrawingEngine->SetHighColor(RGBColor(0, 0, 0));
888+ fDrawingEngine->StrokeLine(offset, pt2);
889+
890+ pt2 = r.LeftBottom();
891+ pt2.x++;
892+ fDrawingEngine->StrokeLine(offset, pt2);
893+
894+ // Black outline
895+ rect.InsetBy(1, 1);
896+ fDrawingEngine->SetHighColor(RGBColor(33, 33, 33));
897+ fDrawingEngine->StrokeRect(rect);
898+
899+ // Double-shaded button
900+ rect.InsetBy(1, 1);
901+ fDrawingEngine->SetHighColor(RGBColor(140, 140, 140));
902+ fDrawingEngine->StrokeLine(rect.RightBottom(), rect.RightTop());
903+ fDrawingEngine->StrokeLine(rect.RightBottom(), rect.LeftBottom());
904+ fDrawingEngine->SetHighColor(RGBColor(206, 206, 206));
905+ fDrawingEngine->StrokeLine(rect.LeftBottom(), rect.LeftTop());
906+ fDrawingEngine->StrokeLine(rect.LeftTop(), rect.RightTop());
907+ fDrawingEngine->SetHighColor(RGBColor(255, 255, 255));
908+ fDrawingEngine->StrokeLine(rect.LeftTop(), rect.LeftTop());
909+
910+ rect.InsetBy(1, 1);
911+ _DrawBlendedRect(fDrawingEngine, rect, !down);
912+}
913+
914+
915+/*! \brief Draws a rectangle with a gradient.
916+ \param down The rectangle should be drawn recessed or not
917+*/
918+void
919+MacDecorator::_DrawBlendedRect(DrawingEngine* engine, BRect rect,
920+ bool down/*, bool focus*/)
921+{
922+ // figure out which colors to use
923+ rgb_color startColor, endColor;
924+ if (down) {
925+ startColor = fButtonLowColor;
926+ endColor = fFrameHighColor;
927+ } else {
928+ startColor = fButtonHighColor;
929+ endColor = fFrameLowerColor;
930+ }
931+
932+ // fill
933+ BGradientLinear gradient;
934+ gradient.SetStart(rect.LeftTop());
935+ gradient.SetEnd(rect.RightBottom());
936+ gradient.AddColor(startColor, 0);
937+ gradient.AddColor(endColor, 255);
938+
939+ engine->FillRect(rect, gradient);
940+}
941+
942+
943+// #pragma mark - DecorAddOn
944+
945+
946+extern "C" DecorAddOn*
947+instantiate_decor_addon(image_id id, const char* name)
948+{
949+ return new (std::nothrow)MacDecorAddOn(id, name);
950+}
+100,
-0
1@@ -0,0 +1,100 @@
2+/*
3+ * Copyright 2009-2014 Haiku, Inc. All rights reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm, bpmagic@columbus.rr.com
8+ * Adrien Destugues, pulkomandy@gmail.com
9+ * John Scipione, jscipione@gmail.com
10+ */
11+#ifndef MAC_DECORATOR_H
12+#define MAC_DECORATOR_H
13+
14+
15+#include "DecorManager.h"
16+#include "RGBColor.h"
17+#include "SATDecorator.h"
18+
19+
20+class MacDecorAddOn : public DecorAddOn {
21+public:
22+ MacDecorAddOn(image_id id, const char* name);
23+
24+protected:
25+ virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
26+ BRect rect, Desktop* desktop);
27+};
28+
29+
30+class MacDecorator: public SATDecorator {
31+public:
32+ MacDecorator(DesktopSettings& settings,
33+ BRect frame, Desktop* desktop);
34+ virtual ~MacDecorator();
35+
36+ void Draw(BRect updateRect);
37+ void Draw();
38+
39+ virtual Region RegionAt(BPoint where, int32& tab) const;
40+
41+ virtual bool SetRegionHighlight(Region region,
42+ uint8 highlight, BRegion* dirty,
43+ int32 tab = -1);
44+
45+protected:
46+ void _DoLayout();
47+
48+ virtual void _DrawFrame(BRect invalid);
49+
50+ virtual void _DrawTab(Decorator::Tab* tab, BRect invalid);
51+ virtual void _DrawButtons(Decorator::Tab* tab,
52+ const BRect& invalid);
53+ virtual void _DrawTitle(Decorator::Tab* tab, BRect rect);
54+
55+ virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
56+ BRect rect);
57+ virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
58+ BRect rect);
59+ virtual void _DrawClose(Decorator::Tab* tab, bool direct,
60+ BRect rect);
61+
62+ virtual void _SetTitle(Tab* tab, const char* string,
63+ BRegion* updateRegion = NULL);
64+
65+ virtual void _MoveBy(BPoint offset);
66+ virtual void _ResizeBy(BPoint offset, BRegion* dirty);
67+
68+ Decorator::Tab* _AllocateNewTab();
69+
70+ virtual bool _AddTab(DesktopSettings& settings,
71+ int32 index = -1,
72+ BRegion* updateRegion = NULL);
73+ virtual bool _RemoveTab(int32 index,
74+ BRegion* updateRegion = NULL);
75+ virtual bool _MoveTab(int32 from, int32 to, bool isMoving,
76+ BRegion* updateRegion = NULL);
77+
78+ virtual void _GetFootprint(BRegion *region);
79+
80+ virtual void _UpdateFont(DesktopSettings& settings);
81+
82+private:
83+ void _DrawButton(Decorator::Tab* tab, bool direct,
84+ BRect rect, bool pressed);
85+ void _DrawBlendedRect(DrawingEngine* engine,
86+ BRect r, bool down);
87+
88+ rgb_color fButtonHighColor;
89+ rgb_color fButtonLowColor;
90+
91+ rgb_color fFrameHighColor;
92+ rgb_color fFrameMidColor;
93+ rgb_color fFrameLowColor;
94+ rgb_color fFrameLowerColor;
95+
96+ rgb_color fFocusTextColor;
97+ rgb_color fNonFocusTextColor;
98+};
99+
100+
101+#endif // MAC_DECORATOR_H
+10,
-0
1@@ -0,0 +1,10 @@
2+resource("be:decor:info") message('deco') {
3+ "name" = "FlatDecorator v1.3",
4+ "authors" = "nhtello v1.3",
5+ "short_descr" = "Decorator flat look - Haiku Inc",
6+ "long_descr" = "",
7+ "lic_url" = "",
8+ "lic_name" = "MIT",
9+ "support_url" = "http://www.haiku-os.org/",
10+ float "version" = 1.3
11+};
+87,
-0
1@@ -0,0 +1,87 @@
2+/*
3+ * Copyright 2010-2011, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Stephan Aßmus <superstippi@gmx.de>
8+ * Ingo Weinhold <ingo_weinhold@gmx.de>
9+ * Clemens Zeidler <haiku@clemens-zeidler.de>
10+ */
11+
12+
13+#include "MagneticBorder.h"
14+
15+#include "Decorator.h"
16+#include "Window.h"
17+#include "Screen.h"
18+
19+
20+MagneticBorder::MagneticBorder()
21+ :
22+ fLastSnapTime(0)
23+{
24+
25+}
26+
27+
28+bool
29+MagneticBorder::AlterDeltaForSnap(Window* window, BPoint& delta, bigtime_t now)
30+{
31+ BRect frame = window->Frame();
32+ Decorator* decorator = window->Decorator();
33+ if (decorator)
34+ frame = decorator->GetFootprint().Frame();
35+
36+ return AlterDeltaForSnap(window->Screen(), frame, delta, now);
37+}
38+
39+
40+bool
41+MagneticBorder::AlterDeltaForSnap(const Screen* screen, BRect& frame,
42+ BPoint& delta, bigtime_t now)
43+{
44+ // Alter the delta (which is a proposed offset used while dragging a
45+ // window) so that the frame of the window 'snaps' to the edges of the
46+ // screen.
47+
48+ const bigtime_t kSnappingDuration = 1500000LL;
49+ const bigtime_t kSnappingPause = 3000000LL;
50+ const float kSnapDistance = 8.0f;
51+
52+ if (now - fLastSnapTime > kSnappingDuration
53+ && now - fLastSnapTime < kSnappingPause) {
54+ // Maintain a pause between snapping.
55+ return false;
56+ }
57+
58+ // TODO: Perhaps obtain the usable area (not covered by the Deskbar)?
59+ BRect screenFrame = screen->Frame();
60+ BRect originalFrame = frame;
61+ frame.OffsetBy(delta);
62+
63+ float leftDist = fabs(frame.left - screenFrame.left);
64+ float topDist = fabs(frame.top - screenFrame.top);
65+ float rightDist = fabs(frame.right - screenFrame.right);
66+ float bottomDist = fabs(frame.bottom - screenFrame.bottom);
67+
68+ bool snapped = false;
69+ if (leftDist < kSnapDistance || rightDist < kSnapDistance) {
70+ snapped = true;
71+ if (leftDist < rightDist)
72+ delta.x = screenFrame.left - originalFrame.left;
73+ else
74+ delta.x = screenFrame.right - originalFrame.right;
75+ }
76+
77+ if (topDist < kSnapDistance || bottomDist < kSnapDistance) {
78+ snapped = true;
79+ if (topDist < bottomDist)
80+ delta.y = screenFrame.top - originalFrame.top;
81+ else
82+ delta.y = screenFrame.bottom - originalFrame.bottom;
83+ }
84+ if (snapped && now - fLastSnapTime > kSnappingPause)
85+ fLastSnapTime = now;
86+
87+ return snapped;
88+}
+34,
-0
1@@ -0,0 +1,34 @@
2+/*
3+ * Copyright 2011, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Clemens Zeidler <haiku@clemens-zeidler.de>
8+ */
9+#ifndef MAGNETIC_BORDRER_H
10+#define MAGNETIC_BORDRER_H
11+
12+
13+#include <Point.h>
14+#include <Screen.h>
15+
16+
17+class Screen;
18+class Window;
19+
20+
21+class MagneticBorder {
22+public:
23+ MagneticBorder();
24+
25+ bool AlterDeltaForSnap(Window* window, BPoint& delta,
26+ bigtime_t now);
27+ bool AlterDeltaForSnap(const Screen* screen,
28+ BRect& frame, BPoint& delta, bigtime_t now);
29+
30+private:
31+ bigtime_t fLastSnapTime;
32+};
33+
34+
35+#endif // MAGNETIC_BORDRER_H
+131,
-0
1@@ -0,0 +1,131 @@
2+## Haiku Generic Makefile v2.6 ##
3+
4+## Fill in this file to specify the project being created, and the referenced
5+## Makefile-Engine will do all of the hard work for you. This handles any
6+## architecture of Haiku.
7+##
8+## For more information, see:
9+## file:///system/develop/documentation/makefile-engine.html
10+
11+# The name of the binary.
12+NAME = MacDecorator
13+
14+# The type of binary, must be one of:
15+# APP: Application
16+# SHARED: Shared library or add-on
17+# STATIC: Static library archive
18+# DRIVER: Kernel driver
19+TYPE = SHARED
20+
21+# If you plan to use localization, specify the application's MIME signature.
22+APP_MIME_SIG =
23+
24+# The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are
25+# so that Pe and Eddie can fill them in for you.
26+#%{
27+# @src->@
28+
29+# Specify the source files to use. Full paths or paths relative to the
30+# Makefile can be included. All files, regardless of directory, will have
31+# their object files created in the common object directory. Note that this
32+# means this Makefile will not work correctly if two source files with the
33+# same name (source.c or source.cpp) are included from different directories.
34+# Also note that spaces in folder names do not work well with this Makefile.
35+SRCS = FlatDecorator.cpp
36+
37+# Specify the resource definition files to use. Full or relative paths can be
38+# used.
39+RDEFS = resources.rdef
40+
41+# Specify the resource files to use. Full or relative paths can be used.
42+# Both RDEFS and RSRCS can be utilized in the same Makefile.
43+RSRCS =
44+
45+# End Pe/Eddie support.
46+# @<-src@
47+#%}
48+
49+# Specify libraries to link against.
50+# There are two acceptable forms of library specifications:
51+# - if your library follows the naming pattern of libXXX.so or libXXX.a,
52+# you can simply specify XXX for the library. (e.g. the entry for
53+# "libtracker.so" would be "tracker")
54+#
55+# - for GCC-independent linking of standard C++ libraries, you can use
56+# $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names.
57+#
58+# - if your library does not follow the standard library naming scheme,
59+# you need to specify the path to the library and it's name.
60+# (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a")
61+LIBS = $(STDCPPLIBS) be
62+
63+# Specify additional paths to directories following the standard libXXX.so
64+# or libXXX.a naming scheme. You can specify full paths or paths relative
65+# to the Makefile. The paths included are not parsed recursively, so
66+# include all of the paths where libraries must be found. Directories where
67+# source files were specified are automatically included.
68+LIBPATHS =
69+
70+# Additional paths to look for system headers. These use the form
71+# "#include <header>". Directories that contain the files in SRCS are
72+# NOT auto-included here.
73+SYSTEM_INCLUDE_PATHS = includes
74+
75+# Additional paths paths to look for local headers. These use the form
76+# #include "header". Directories that contain the files in SRCS are
77+# automatically included.
78+LOCAL_INCLUDE_PATHS = includes
79+
80+# Specify the level of optimization that you want. Specify either NONE (O0),
81+# SOME (O1), FULL (O3), or leave blank (for the default optimization level).
82+OPTIMIZE :=
83+
84+# Specify the codes for languages you are going to support in this
85+# application. The default "en" one must be provided too. "make catkeys"
86+# will recreate only the "locales/en.catkeys" file. Use it as a template
87+# for creating catkeys for other languages. All localization files must be
88+# placed in the "locales" subdirectory.
89+LOCALES =
90+
91+# Specify all the preprocessor symbols to be defined. The symbols will not
92+# have their values set automatically; you must supply the value (if any) to
93+# use. For example, setting DEFINES to "DEBUG=1" will cause the compiler
94+# option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass
95+# "-DDEBUG" on the compiler's command line.
96+DEFINES =
97+
98+# Specify the warning level. Either NONE (suppress all warnings),
99+# ALL (enable all warnings), or leave blank (enable default warnings).
100+WARNINGS =
101+
102+# With image symbols, stack crawls in the debugger are meaningful.
103+# If set to "TRUE", symbols will be created.
104+SYMBOLS :=
105+
106+# Includes debug information, which allows the binary to be debugged easily.
107+# If set to "TRUE", debug info will be created.
108+DEBUGGER :=
109+
110+# Specify any additional compiler flags to be used.
111+COMPILER_FLAGS =
112+
113+# Specify any additional linker flags to be used.
114+LINKER_FLAGS =
115+
116+# Specify the version of this binary. Example:
117+# -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL"
118+# This may also be specified in a resource.
119+APP_VERSION :=
120+
121+# (Only used when "TYPE" is "DRIVER"). Specify the desired driver install
122+# location in the /dev hierarchy. Example:
123+# DRIVER_PATH = video/usb
124+# will instruct the "driverinstall" rule to place a symlink to your driver's
125+# binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will
126+# appear at /dev/video/usb when loaded. The default is "misc".
127+DRIVER_PATH =
128+
129+## Include the Makefile-Engine
130+DEVEL_DIRECTORY := \
131+ $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY)
132+include $(DEVEL_DIRECTORY)/etc/makefile-engine
+131,
-0
1@@ -0,0 +1,131 @@
2+## Haiku Generic Makefile v2.6 ##
3+
4+## Fill in this file to specify the project being created, and the referenced
5+## Makefile-Engine will do all of the hard work for you. This handles any
6+## architecture of Haiku.
7+##
8+## For more information, see:
9+## file:///system/develop/documentation/makefile-engine.html
10+
11+# The name of the binary.
12+NAME = FlatDecorator
13+
14+# The type of binary, must be one of:
15+# APP: Application
16+# SHARED: Shared library or add-on
17+# STATIC: Static library archive
18+# DRIVER: Kernel driver
19+TYPE = SHARED
20+
21+# If you plan to use localization, specify the application's MIME signature.
22+APP_MIME_SIG =
23+
24+# The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are
25+# so that Pe and Eddie can fill them in for you.
26+#%{
27+# @src->@
28+
29+# Specify the source files to use. Full paths or paths relative to the
30+# Makefile can be included. All files, regardless of directory, will have
31+# their object files created in the common object directory. Note that this
32+# means this Makefile will not work correctly if two source files with the
33+# same name (source.c or source.cpp) are included from different directories.
34+# Also note that spaces in folder names do not work well with this Makefile.
35+SRCS = FlatDecorator.cpp
36+
37+# Specify the resource definition files to use. Full or relative paths can be
38+# used.
39+RDEFS = resources.rdef
40+
41+# Specify the resource files to use. Full or relative paths can be used.
42+# Both RDEFS and RSRCS can be utilized in the same Makefile.
43+RSRCS =
44+
45+# End Pe/Eddie support.
46+# @<-src@
47+#%}
48+
49+# Specify libraries to link against.
50+# There are two acceptable forms of library specifications:
51+# - if your library follows the naming pattern of libXXX.so or libXXX.a,
52+# you can simply specify XXX for the library. (e.g. the entry for
53+# "libtracker.so" would be "tracker")
54+#
55+# - for GCC-independent linking of standard C++ libraries, you can use
56+# $(STDCPPLIBS) instead of the raw "stdc++[.r4] [supc++]" library names.
57+#
58+# - if your library does not follow the standard library naming scheme,
59+# you need to specify the path to the library and it's name.
60+# (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a")
61+LIBS = $(STDCPPLIBS) be
62+
63+# Specify additional paths to directories following the standard libXXX.so
64+# or libXXX.a naming scheme. You can specify full paths or paths relative
65+# to the Makefile. The paths included are not parsed recursively, so
66+# include all of the paths where libraries must be found. Directories where
67+# source files were specified are automatically included.
68+LIBPATHS =
69+
70+# Additional paths to look for system headers. These use the form
71+# "#include <header>". Directories that contain the files in SRCS are
72+# NOT auto-included here.
73+SYSTEM_INCLUDE_PATHS = includes
74+
75+# Additional paths paths to look for local headers. These use the form
76+# #include "header". Directories that contain the files in SRCS are
77+# automatically included.
78+LOCAL_INCLUDE_PATHS = includes
79+
80+# Specify the level of optimization that you want. Specify either NONE (O0),
81+# SOME (O1), FULL (O3), or leave blank (for the default optimization level).
82+OPTIMIZE :=
83+
84+# Specify the codes for languages you are going to support in this
85+# application. The default "en" one must be provided too. "make catkeys"
86+# will recreate only the "locales/en.catkeys" file. Use it as a template
87+# for creating catkeys for other languages. All localization files must be
88+# placed in the "locales" subdirectory.
89+LOCALES =
90+
91+# Specify all the preprocessor symbols to be defined. The symbols will not
92+# have their values set automatically; you must supply the value (if any) to
93+# use. For example, setting DEFINES to "DEBUG=1" will cause the compiler
94+# option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG" would pass
95+# "-DDEBUG" on the compiler's command line.
96+DEFINES =
97+
98+# Specify the warning level. Either NONE (suppress all warnings),
99+# ALL (enable all warnings), or leave blank (enable default warnings).
100+WARNINGS =
101+
102+# With image symbols, stack crawls in the debugger are meaningful.
103+# If set to "TRUE", symbols will be created.
104+SYMBOLS :=
105+
106+# Includes debug information, which allows the binary to be debugged easily.
107+# If set to "TRUE", debug info will be created.
108+DEBUGGER :=
109+
110+# Specify any additional compiler flags to be used.
111+COMPILER_FLAGS =
112+
113+# Specify any additional linker flags to be used.
114+LINKER_FLAGS =
115+
116+# Specify the version of this binary. Example:
117+# -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL"
118+# This may also be specified in a resource.
119+APP_VERSION :=
120+
121+# (Only used when "TYPE" is "DRIVER"). Specify the desired driver install
122+# location in the /dev hierarchy. Example:
123+# DRIVER_PATH = video/usb
124+# will instruct the "driverinstall" rule to place a symlink to your driver's
125+# binary in ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will
126+# appear at /dev/video/usb when loaded. The default is "misc".
127+DRIVER_PATH =
128+
129+## Include the Makefile-Engine
130+DEVEL_DIRECTORY := \
131+ $(shell findpaths -r "makefile_engine" B_FIND_PATH_DEVELOP_DIRECTORY)
132+include $(DEVEL_DIRECTORY)/etc/makefile-engine
+1100,
-0
1@@ -0,0 +1,1100 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * Ryan Leavengood, leavengood@gmail.com
10+ * Philippe Saint-Pierre, stpere@gmail.com
11+ * John Scipione, jscipione@gmail.com
12+ * Ingo Weinhold, ingo_weinhold@gmx.de
13+ * Clemens Zeidler, haiku@clemens-zeidler.de
14+ * Joseph Groover, looncraz@looncraz.net
15+ * Jacob Secunda, secundaja@gmail.com
16+ */
17+
18+
19+/*! Decorator made up of tabs */
20+
21+
22+#include "TabDecorator.h"
23+
24+#include <algorithm>
25+#include <cmath>
26+#include <new>
27+#include <stdio.h>
28+
29+#include <Autolock.h>
30+#include <Debug.h>
31+#include <GradientLinear.h>
32+#include <Rect.h>
33+#include <View.h>
34+
35+#include <WindowPrivate.h>
36+
37+#include "BitmapDrawingEngine.h"
38+#include "DesktopSettings.h"
39+#include "DrawingEngine.h"
40+#include "DrawState.h"
41+#include "FontManager.h"
42+#include "PatternHandler.h"
43+
44+
45+//#define DEBUG_DECORATOR
46+#ifdef DEBUG_DECORATOR
47+# define STRACE(x) printf x
48+#else
49+# define STRACE(x) ;
50+#endif
51+
52+
53+static bool
54+int_equal(float x, float y)
55+{
56+ return abs(x - y) <= 1;
57+}
58+
59+
60+static const float kBorderResizeLength = 22.0;
61+static const float kResizeKnobSize = 18.0;
62+
63+
64+// #pragma mark -
65+
66+
67+// TODO: get rid of DesktopSettings here, and introduce private accessor
68+// methods to the Decorator base class
69+TabDecorator::TabDecorator(DesktopSettings& settings, BRect frame,
70+ Desktop* desktop)
71+ :
72+ Decorator(settings, frame, desktop),
73+ fOldMovingTab(0, 0, -1, -1)
74+{
75+ STRACE(("TabDecorator:\n"));
76+ STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
77+ frame.left, frame.top, frame.right, frame.bottom));
78+
79+ // TODO: If the decorator was created with a frame too small, it should
80+ // resize itself!
81+}
82+
83+
84+TabDecorator::~TabDecorator()
85+{
86+ STRACE(("TabDecorator: ~TabDecorator()\n"));
87+}
88+
89+
90+// #pragma mark - Public methods
91+
92+
93+/*! \brief Updates the decorator in the rectangular area \a updateRect.
94+
95+ Updates all areas which intersect the frame and tab.
96+
97+ \param updateRect The rectangular area to update.
98+*/
99+void
100+TabDecorator::Draw(BRect updateRect)
101+{
102+ STRACE(("TabDecorator::Draw(BRect "
103+ "updateRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f))\n",
104+ updateRect.left, updateRect.top, updateRect.right, updateRect.bottom));
105+
106+ fDrawingEngine->SetDrawState(&fDrawState);
107+
108+ _DrawFrame(updateRect & fBorderRect);
109+
110+ if (IsOutlineResizing())
111+ _DrawOutlineFrame(updateRect & fOutlineBorderRect);
112+
113+ _DrawTabs(updateRect & fTitleBarRect);
114+}
115+
116+
117+//! Forces a complete decorator update
118+void
119+TabDecorator::Draw()
120+{
121+ STRACE(("TabDecorator: Draw()"));
122+
123+ fDrawingEngine->SetDrawState(&fDrawState);
124+
125+ _DrawFrame(fBorderRect);
126+
127+ if (IsOutlineResizing())
128+ _DrawOutlineFrame(fOutlineBorderRect);
129+
130+ _DrawTabs(fTitleBarRect);
131+}
132+
133+
134+Decorator::Region
135+TabDecorator::RegionAt(BPoint where, int32& tab) const
136+{
137+ // Let the base class version identify hits of the buttons and the tab.
138+ Region region = Decorator::RegionAt(where, tab);
139+ if (region != REGION_NONE)
140+ return region;
141+
142+ // check the resize corner
143+ if (fTopTab->look == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
144+ return REGION_RIGHT_BOTTOM_CORNER;
145+
146+ // hit-test the borders
147+ if (fLeftBorder.Contains(where))
148+ return REGION_LEFT_BORDER;
149+ if (fTopBorder.Contains(where))
150+ return REGION_TOP_BORDER;
151+
152+ // Part of the bottom and right borders may be a resize-region, so we have
153+ // to check explicitly, if it has been it.
154+ if (fRightBorder.Contains(where))
155+ region = REGION_RIGHT_BORDER;
156+ else if (fBottomBorder.Contains(where))
157+ region = REGION_BOTTOM_BORDER;
158+ else
159+ return REGION_NONE;
160+
161+ // check resize area
162+ if ((fTopTab->flags & B_NOT_RESIZABLE) == 0
163+ && (fTopTab->look == B_TITLED_WINDOW_LOOK
164+ || fTopTab->look == B_FLOATING_WINDOW_LOOK
165+ || fTopTab->look == B_MODAL_WINDOW_LOOK
166+ || fTopTab->look == kLeftTitledWindowLook)) {
167+ BRect resizeRect(BPoint(fBottomBorder.right - fBorderResizeLength,
168+ fBottomBorder.bottom - fBorderResizeLength),
169+ fBottomBorder.RightBottom());
170+ if (resizeRect.Contains(where))
171+ return REGION_RIGHT_BOTTOM_CORNER;
172+ }
173+
174+ return region;
175+}
176+
177+
178+bool
179+TabDecorator::SetRegionHighlight(Region region, uint8 highlight,
180+ BRegion* dirty, int32 tabIndex)
181+{
182+ Decorator::Tab* tab
183+ = static_cast<Decorator::Tab*>(_TabAt(tabIndex));
184+ if (tab != NULL) {
185+ tab->isHighlighted = highlight != 0;
186+ // Invalidate the bitmap caches for the close/zoom button, when the
187+ // highlight changes.
188+ switch (region) {
189+ case REGION_CLOSE_BUTTON:
190+ if (highlight != RegionHighlight(region))
191+ memset(&tab->closeBitmaps, 0, sizeof(tab->closeBitmaps));
192+ break;
193+ case REGION_ZOOM_BUTTON:
194+ if (highlight != RegionHighlight(region))
195+ memset(&tab->zoomBitmaps, 0, sizeof(tab->zoomBitmaps));
196+ break;
197+ default:
198+ break;
199+ }
200+ }
201+
202+ return Decorator::SetRegionHighlight(region, highlight, dirty, tabIndex);
203+}
204+
205+
206+void
207+TabDecorator::UpdateColors(DesktopSettings& settings)
208+{
209+ // Desktop is write locked, so be quick about it.
210+ fFocusFrameColor = settings.UIColor(B_WINDOW_BORDER_COLOR);
211+ fFocusTabColor = settings.UIColor(B_WINDOW_TAB_COLOR);
212+ fFocusTabColorLight = tint_color(fFocusTabColor,
213+ (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
214+ fFocusTabColorBevel = tint_color(fFocusTabColor, B_LIGHTEN_2_TINT);
215+ fFocusTabColorShadow = tint_color(fFocusTabColor,
216+ (B_DARKEN_1_TINT + B_NO_TINT) / 2);
217+ fFocusTextColor = settings.UIColor(B_WINDOW_TEXT_COLOR);
218+
219+ fNonFocusFrameColor = settings.UIColor(B_WINDOW_INACTIVE_BORDER_COLOR);
220+ fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
221+ fNonFocusTabColorLight = tint_color(fNonFocusTabColor,
222+ (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
223+ fNonFocusTabColorBevel = tint_color(fNonFocusTabColor, B_LIGHTEN_2_TINT);
224+ fNonFocusTabColorShadow = tint_color(fNonFocusTabColor,
225+ (B_DARKEN_1_TINT + B_NO_TINT) / 2);
226+ fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
227+}
228+
229+
230+void
231+TabDecorator::_DoLayout()
232+{
233+ STRACE(("TabDecorator: Do Layout\n"));
234+ // Here we determine the size of every rectangle that we use
235+ // internally when we are given the size of the client rectangle.
236+
237+ bool hasTab = false;
238+
239+ // TODO: Put this computation somewhere more central!
240+ const float scaleFactor = max_c(fDrawState.Font().Size() / 12.0f, 1.0f);
241+
242+ switch ((int)fTopTab->look) {
243+ case B_MODAL_WINDOW_LOOK:
244+ fBorderWidth = 5;
245+ break;
246+
247+ case B_TITLED_WINDOW_LOOK:
248+ case B_DOCUMENT_WINDOW_LOOK:
249+ hasTab = true;
250+ fBorderWidth = 5;
251+ break;
252+ case B_FLOATING_WINDOW_LOOK:
253+ case kLeftTitledWindowLook:
254+ hasTab = true;
255+ fBorderWidth = 3;
256+ break;
257+
258+ case B_BORDERED_WINDOW_LOOK:
259+ fBorderWidth = 1;
260+ break;
261+
262+ default:
263+ fBorderWidth = 0;
264+ }
265+
266+ fBorderWidth = int32(fBorderWidth * scaleFactor);
267+ fResizeKnobSize = kResizeKnobSize * scaleFactor;
268+ fBorderResizeLength = kBorderResizeLength * scaleFactor;
269+
270+ // calculate left/top/right/bottom borders
271+ if (fBorderWidth > 0) {
272+ // NOTE: no overlapping, the left and right border rects
273+ // don't include the corners!
274+ fLeftBorder.Set(fFrame.left - fBorderWidth, fFrame.top,
275+ fFrame.left - 1, fFrame.bottom);
276+
277+ fRightBorder.Set(fFrame.right + 1, fFrame.top ,
278+ fFrame.right + fBorderWidth, fFrame.bottom);
279+
280+ fTopBorder.Set(fFrame.left - fBorderWidth, fFrame.top - fBorderWidth,
281+ fFrame.right + fBorderWidth, fFrame.top - 1);
282+
283+ fBottomBorder.Set(fFrame.left - fBorderWidth, fFrame.bottom + 1,
284+ fFrame.right + fBorderWidth, fFrame.bottom + fBorderWidth);
285+ } else {
286+ // no border
287+ fLeftBorder.Set(0.0, 0.0, -1.0, -1.0);
288+ fRightBorder.Set(0.0, 0.0, -1.0, -1.0);
289+ fTopBorder.Set(0.0, 0.0, -1.0, -1.0);
290+ fBottomBorder.Set(0.0, 0.0, -1.0, -1.0);
291+ }
292+
293+ fBorderRect = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
294+
295+ // calculate resize rect
296+ if (fBorderWidth > 1) {
297+ fResizeRect.Set(fBottomBorder.right - fResizeKnobSize,
298+ fBottomBorder.bottom - fResizeKnobSize, fBottomBorder.right,
299+ fBottomBorder.bottom);
300+ } else {
301+ // no border or one pixel border (menus and such)
302+ fResizeRect.Set(0, 0, -1, -1);
303+ }
304+
305+ if (hasTab) {
306+ _DoTabLayout();
307+ return;
308+ } else {
309+ // no tab
310+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
311+ Decorator::Tab* tab = fTabList.ItemAt(i);
312+ tab->tabRect.Set(0.0, 0.0, -1.0, -1.0);
313+ }
314+ fTabsRegion.MakeEmpty();
315+ fTitleBarRect.Set(0.0, 0.0, -1.0, -1.0);
316+ }
317+}
318+
319+
320+void
321+TabDecorator::_DoOutlineLayout()
322+{
323+ fOutlineBorderWidth = 1;
324+
325+ // calculate left/top/right/bottom outline borders
326+ // NOTE: no overlapping, the left and right border rects
327+ // don't include the corners!
328+ fLeftOutlineBorder.Set(fFrame.left - fOutlineBorderWidth, fFrame.top,
329+ fFrame.left - 1, fFrame.bottom);
330+
331+ fRightOutlineBorder.Set(fFrame.right + 1, fFrame.top ,
332+ fFrame.right + fOutlineBorderWidth, fFrame.bottom);
333+
334+ fTopOutlineBorder.Set(fFrame.left - fOutlineBorderWidth,
335+ fFrame.top - fOutlineBorderWidth,
336+ fFrame.right + fOutlineBorderWidth, fFrame.top - 1);
337+
338+ fBottomOutlineBorder.Set(fFrame.left - fOutlineBorderWidth,
339+ fFrame.bottom + 1,
340+ fFrame.right + fOutlineBorderWidth,
341+ fFrame.bottom + fOutlineBorderWidth);
342+
343+ fOutlineBorderRect = BRect(fTopOutlineBorder.LeftTop(),
344+ fBottomOutlineBorder.RightBottom());
345+}
346+
347+
348+void
349+TabDecorator::_DoTabLayout()
350+{
351+ float tabOffset = 0;
352+ if (fTabList.CountItems() == 1) {
353+ float tabSize;
354+ tabOffset = _SingleTabOffsetAndSize(tabSize);
355+ }
356+
357+ float sumTabWidth = 0;
358+ // calculate our tab rect
359+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
360+ Decorator::Tab* tab = _TabAt(i);
361+
362+ BRect& tabRect = tab->tabRect;
363+ // distance from one item of the tab bar to another.
364+ // In this case the text and close/zoom rects
365+ tab->textOffset = _DefaultTextOffset();
366+
367+ font_height fontHeight;
368+ fDrawState.Font().GetHeight(fontHeight);
369+
370+ if (tab->look != kLeftTitledWindowLook) {
371+ const float spacing = fBorderWidth * 1.4f;
372+ tabRect.Set(fFrame.left - fBorderWidth,
373+ fFrame.top - fBorderWidth
374+ - ceilf(fontHeight.ascent + fontHeight.descent + spacing),
375+ ((fFrame.right - fFrame.left) < (spacing * 5) ?
376+ fFrame.left + (spacing * 5) : fFrame.right) + fBorderWidth,
377+ fFrame.top - fBorderWidth);
378+ } else {
379+ tabRect.Set(fFrame.left - fBorderWidth
380+ - ceilf(fontHeight.ascent + fontHeight.descent + fBorderWidth),
381+ fFrame.top - fBorderWidth, fFrame.left - fBorderWidth,
382+ fFrame.bottom + fBorderWidth);
383+ }
384+
385+ // format tab rect for a floating window - make the rect smaller
386+ if (tab->look == B_FLOATING_WINDOW_LOOK) {
387+ tabRect.InsetBy(0, 2);
388+ tabRect.OffsetBy(0, 2);
389+ }
390+
391+ float offset;
392+ float size;
393+ float inset;
394+ _GetButtonSizeAndOffset(tabRect, &offset, &size, &inset);
395+
396+ // tab->minTabSize contains just the room for the buttons
397+ tab->minTabSize = inset * 2 + tab->textOffset;
398+ if ((tab->flags & B_NOT_CLOSABLE) == 0)
399+ tab->minTabSize += offset + size;
400+ if ((tab->flags & B_NOT_ZOOMABLE) == 0)
401+ tab->minTabSize += offset + size;
402+
403+ // tab->maxTabSize contains tab->minTabSize + the width required for the
404+ // title
405+ tab->maxTabSize = fDrawingEngine
406+ ? ceilf(fDrawingEngine->StringWidth(Title(tab), strlen(Title(tab)),
407+ fDrawState.Font())) : 0.0;
408+ if (tab->maxTabSize > 0.0)
409+ tab->maxTabSize += tab->textOffset;
410+ tab->maxTabSize += tab->minTabSize;
411+
412+ float tabSize = (tab->look != kLeftTitledWindowLook
413+ ? fFrame.Width() : fFrame.Height()) + fBorderWidth * 2;
414+ if (tabSize < tab->minTabSize)
415+ tabSize = tab->minTabSize;
416+ if (tabSize > tab->maxTabSize)
417+ tabSize = tab->maxTabSize;
418+
419+ // layout buttons and truncate text
420+ if (tab->look != kLeftTitledWindowLook)
421+ tabRect.right = tabRect.left + tabSize;
422+ else
423+ tabRect.bottom = tabRect.top + tabSize;
424+
425+ // make sure fTabOffset is within limits and apply it to
426+ // the tabRect
427+ tab->tabOffset = (uint32)tabOffset;
428+ if (tab->tabLocation != 0.0 && fTabList.CountItems() == 1
429+ && tab->tabOffset > (fRightBorder.right - fLeftBorder.left
430+ - tabRect.Width())) {
431+ tab->tabOffset = uint32(fRightBorder.right - fLeftBorder.left
432+ - tabRect.Width());
433+ }
434+ tabRect.OffsetBy(tab->tabOffset, 0);
435+ tabOffset += tabRect.Width();
436+
437+ sumTabWidth += tabRect.Width();
438+ }
439+
440+ float windowWidth = fFrame.Width() + 2 * fBorderWidth;
441+ if (CountTabs() > 1 && sumTabWidth > windowWidth)
442+ _DistributeTabSize(sumTabWidth - windowWidth);
443+
444+ // finally, layout the buttons and text within the tab rect
445+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
446+ Decorator::Tab* tab = fTabList.ItemAt(i);
447+
448+ if (i == 0)
449+ fTitleBarRect = tab->tabRect;
450+ else
451+ fTitleBarRect = fTitleBarRect | tab->tabRect;
452+
453+ _LayoutTabItems(tab, tab->tabRect);
454+ }
455+
456+ fTabsRegion = fTitleBarRect;
457+}
458+
459+
460+void
461+TabDecorator::_DistributeTabSize(float delta)
462+{
463+ int32 tabCount = fTabList.CountItems();
464+ ASSERT(tabCount > 1);
465+
466+ float maxTabSize = 0;
467+ float secMaxTabSize = 0;
468+ int32 nTabsWithMaxSize = 0;
469+ for (int32 i = 0; i < tabCount; i++) {
470+ Decorator::Tab* tab = fTabList.ItemAt(i);
471+ if (tab == NULL)
472+ continue;
473+
474+ float tabWidth = tab->tabRect.Width();
475+ if (int_equal(maxTabSize, tabWidth)) {
476+ nTabsWithMaxSize++;
477+ continue;
478+ }
479+ if (maxTabSize < tabWidth) {
480+ secMaxTabSize = maxTabSize;
481+ maxTabSize = tabWidth;
482+ nTabsWithMaxSize = 1;
483+ } else if (secMaxTabSize <= tabWidth)
484+ secMaxTabSize = tabWidth;
485+ }
486+
487+ float minus = ceilf(std::min(maxTabSize - secMaxTabSize, delta));
488+ if (minus < 1.0)
489+ return;
490+ delta -= minus;
491+ minus /= nTabsWithMaxSize;
492+
493+ Decorator::Tab* previousTab = NULL;
494+ for (int32 i = 0; i < tabCount; i++) {
495+ Decorator::Tab* tab = fTabList.ItemAt(i);
496+ if (tab == NULL)
497+ continue;
498+
499+ if (int_equal(maxTabSize, tab->tabRect.Width()))
500+ tab->tabRect.right -= minus;
501+
502+ if (previousTab != NULL) {
503+ float offsetX = previousTab->tabRect.right - tab->tabRect.left;
504+ tab->tabRect.OffsetBy(offsetX, 0);
505+ }
506+
507+ previousTab = tab;
508+ }
509+
510+ if (delta > 0) {
511+ _DistributeTabSize(delta);
512+ return;
513+ }
514+
515+ // done
516+ if (previousTab != NULL)
517+ previousTab->tabRect.right = floorf(fFrame.right + fBorderWidth);
518+
519+ for (int32 i = 0; i < tabCount; i++) {
520+ Decorator::Tab* tab = fTabList.ItemAt(i);
521+ if (tab == NULL)
522+ continue;
523+
524+ tab->tabOffset = uint32(tab->tabRect.left - fLeftBorder.left);
525+ }
526+}
527+
528+
529+void
530+TabDecorator::_DrawOutlineFrame(BRect rect)
531+{
532+ drawing_mode oldMode;
533+
534+ fDrawingEngine->SetDrawingMode(B_OP_ALPHA, oldMode);
535+ fDrawingEngine->SetPattern(B_MIXED_COLORS);
536+ fDrawingEngine->StrokeRect(rect);
537+
538+ fDrawingEngine->SetDrawingMode(oldMode);
539+}
540+
541+
542+void
543+TabDecorator::_SetTitle(Decorator::Tab* tab, const char* string,
544+ BRegion* updateRegion)
545+{
546+ // TODO: we could be much smarter about the update region
547+
548+ BRect rect = TabRect((int32) 0) | TabRect(CountTabs() - 1);
549+ // Get a rect of all the tabs
550+
551+ _DoLayout();
552+ _DoOutlineLayout();
553+
554+ if (updateRegion == NULL)
555+ return;
556+
557+ rect = rect | TabRect(CountTabs() - 1);
558+ // Update the rect to guarantee it updates all the tabs
559+
560+ rect.bottom++;
561+ // the border will look differently when the title is adjacent
562+
563+ updateRegion->Include(rect);
564+}
565+
566+
567+void
568+TabDecorator::_MoveBy(BPoint offset)
569+{
570+ STRACE(("TabDecorator: Move By (%.1f, %.1f)\n", offset.x, offset.y));
571+
572+ // Move all internal rectangles the appropriate amount
573+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
574+ Decorator::Tab* tab = fTabList.ItemAt(i);
575+ tab->zoomRect.OffsetBy(offset);
576+ tab->closeRect.OffsetBy(offset);
577+ tab->tabRect.OffsetBy(offset);
578+ }
579+
580+ fFrame.OffsetBy(offset);
581+ fTitleBarRect.OffsetBy(offset);
582+ fTabsRegion.OffsetBy(offset);
583+ fResizeRect.OffsetBy(offset);
584+ fBorderRect.OffsetBy(offset);
585+
586+ fLeftBorder.OffsetBy(offset);
587+ fRightBorder.OffsetBy(offset);
588+ fTopBorder.OffsetBy(offset);
589+ fBottomBorder.OffsetBy(offset);
590+}
591+
592+
593+void
594+TabDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
595+{
596+ STRACE(("TabDecorator: Resize By (%.1f, %.1f)\n", offset.x, offset.y));
597+
598+ // Move all internal rectangles the appropriate amount
599+ fFrame.right += offset.x;
600+ fFrame.bottom += offset.y;
601+
602+ // Handle invalidation of resize rect
603+ if (dirty != NULL && !(fTopTab->flags & B_NOT_RESIZABLE)) {
604+ BRect realResizeRect;
605+ switch ((int)fTopTab->look) {
606+ case B_DOCUMENT_WINDOW_LOOK:
607+ realResizeRect = fResizeRect;
608+ // Resize rect at old location
609+ dirty->Include(realResizeRect);
610+ realResizeRect.OffsetBy(offset);
611+ // Resize rect at new location
612+ dirty->Include(realResizeRect);
613+ break;
614+
615+ case B_TITLED_WINDOW_LOOK:
616+ case B_FLOATING_WINDOW_LOOK:
617+ case B_MODAL_WINDOW_LOOK:
618+ case kLeftTitledWindowLook:
619+ // The bottom border resize line
620+ realResizeRect.Set(fRightBorder.right - fBorderResizeLength,
621+ fBottomBorder.top,
622+ fRightBorder.right - fBorderResizeLength,
623+ fBottomBorder.bottom - 1);
624+ // Old location
625+ dirty->Include(realResizeRect);
626+ realResizeRect.OffsetBy(offset);
627+ // New location
628+ dirty->Include(realResizeRect);
629+
630+ // The right border resize line
631+ realResizeRect.Set(fRightBorder.left,
632+ fBottomBorder.bottom - fBorderResizeLength,
633+ fRightBorder.right - 1,
634+ fBottomBorder.bottom - fBorderResizeLength);
635+ // Old location
636+ dirty->Include(realResizeRect);
637+ realResizeRect.OffsetBy(offset);
638+ // New location
639+ dirty->Include(realResizeRect);
640+ break;
641+
642+ default:
643+ break;
644+ }
645+ }
646+
647+ fResizeRect.OffsetBy(offset);
648+
649+ fBorderRect.right += offset.x;
650+ fBorderRect.bottom += offset.y;
651+
652+ fLeftBorder.bottom += offset.y;
653+ fTopBorder.right += offset.x;
654+
655+ fRightBorder.OffsetBy(offset.x, 0.0);
656+ fRightBorder.bottom += offset.y;
657+
658+ fBottomBorder.OffsetBy(0.0, offset.y);
659+ fBottomBorder.right += offset.x;
660+
661+ if (dirty) {
662+ if (offset.x > 0.0) {
663+ BRect t(fRightBorder.left - offset.x, fTopBorder.top,
664+ fRightBorder.right, fTopBorder.bottom);
665+ dirty->Include(t);
666+ t.Set(fRightBorder.left - offset.x, fBottomBorder.top,
667+ fRightBorder.right, fBottomBorder.bottom);
668+ dirty->Include(t);
669+ dirty->Include(fRightBorder);
670+ } else if (offset.x < 0.0) {
671+ dirty->Include(BRect(fRightBorder.left, fTopBorder.top,
672+ fRightBorder.right, fBottomBorder.bottom));
673+ }
674+ if (offset.y > 0.0) {
675+ BRect t(fLeftBorder.left, fLeftBorder.bottom - offset.y,
676+ fLeftBorder.right, fLeftBorder.bottom);
677+ dirty->Include(t);
678+ t.Set(fRightBorder.left, fRightBorder.bottom - offset.y,
679+ fRightBorder.right, fRightBorder.bottom);
680+ dirty->Include(t);
681+ dirty->Include(fBottomBorder);
682+ } else if (offset.y < 0.0) {
683+ dirty->Include(fBottomBorder);
684+ }
685+ }
686+
687+ // resize tab and layout tab items
688+ if (fTitleBarRect.IsValid()) {
689+ if (fTabList.CountItems() > 1) {
690+ _DoTabLayout();
691+ if (dirty != NULL)
692+ dirty->Include(fTitleBarRect);
693+ return;
694+ }
695+
696+ Decorator::Tab* tab = _TabAt(0);
697+ BRect& tabRect = tab->tabRect;
698+ BRect oldTabRect(tabRect);
699+
700+ float tabSize;
701+ float tabOffset = _SingleTabOffsetAndSize(tabSize);
702+
703+ float delta = tabOffset - tab->tabOffset;
704+ tab->tabOffset = (uint32)tabOffset;
705+ if (fTopTab->look != kLeftTitledWindowLook)
706+ tabRect.OffsetBy(delta, 0.0);
707+ else
708+ tabRect.OffsetBy(0.0, delta);
709+
710+ if (tabSize < tab->minTabSize)
711+ tabSize = tab->minTabSize;
712+ if (tabSize > tab->maxTabSize)
713+ tabSize = tab->maxTabSize;
714+
715+ if (fTopTab->look != kLeftTitledWindowLook
716+ && tabSize != tabRect.Width()) {
717+ tabRect.right = tabRect.left + tabSize;
718+ } else if (fTopTab->look == kLeftTitledWindowLook
719+ && tabSize != tabRect.Height()) {
720+ tabRect.bottom = tabRect.top + tabSize;
721+ }
722+
723+ if (oldTabRect != tabRect) {
724+ _LayoutTabItems(tab, tabRect);
725+
726+ if (dirty) {
727+ // NOTE: the tab rect becoming smaller only would
728+ // handled be the Desktop anyways, so it is sufficient
729+ // to include it into the dirty region in it's
730+ // final state
731+ BRect redraw(tabRect);
732+ if (delta != 0.0) {
733+ redraw = redraw | oldTabRect;
734+ if (fTopTab->look != kLeftTitledWindowLook)
735+ redraw.bottom++;
736+ else
737+ redraw.right++;
738+ }
739+ dirty->Include(redraw);
740+ }
741+ }
742+ fTitleBarRect = tabRect;
743+ fTabsRegion = fTitleBarRect;
744+ }
745+}
746+
747+
748+void
749+TabDecorator::_SetFocus(Decorator::Tab* tab)
750+{
751+ Decorator::Tab* decoratorTab = static_cast<Decorator::Tab*>(tab);
752+
753+ decoratorTab->buttonFocus = IsFocus(tab)
754+ || ((decoratorTab->look == B_FLOATING_WINDOW_LOOK
755+ || decoratorTab->look == kLeftTitledWindowLook)
756+ && (decoratorTab->flags & B_AVOID_FOCUS) != 0);
757+ if (CountTabs() > 1)
758+ _LayoutTabItems(decoratorTab, decoratorTab->tabRect);
759+}
760+
761+
762+bool
763+TabDecorator::_SetTabLocation(Decorator::Tab* _tab, float location,
764+ bool isShifting, BRegion* updateRegion)
765+{
766+ STRACE(("TabDecorator: Set Tab Location(%.1f)\n", location));
767+
768+ if (CountTabs() > 1) {
769+ if (isShifting == false) {
770+ _DoTabLayout();
771+ if (updateRegion != NULL)
772+ updateRegion->Include(fTitleBarRect);
773+
774+ fOldMovingTab = BRect(0, 0, -1, -1);
775+ return true;
776+ } else {
777+ if (fOldMovingTab.IsValid() == false)
778+ fOldMovingTab = _tab->tabRect;
779+ }
780+ }
781+
782+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
783+ BRect& tabRect = tab->tabRect;
784+ if (tabRect.IsValid() == false)
785+ return false;
786+
787+ if (location < 0)
788+ location = 0;
789+
790+ float maxLocation
791+ = fRightBorder.right - fLeftBorder.left - tabRect.Width();
792+ if (CountTabs() > 1)
793+ maxLocation = fTitleBarRect.right - fLeftBorder.left - tabRect.Width();
794+
795+ if (location > maxLocation)
796+ location = maxLocation;
797+
798+ float delta = floor(location - tab->tabOffset);
799+ if (delta == 0.0)
800+ return false;
801+
802+ // redraw old rect (1 pixel on the border must also be updated)
803+ BRect rect(tabRect);
804+ rect.bottom++;
805+ if (updateRegion != NULL)
806+ updateRegion->Include(rect);
807+
808+ tabRect.OffsetBy(delta, 0);
809+ tab->tabOffset = (int32)location;
810+ _LayoutTabItems(_tab, tabRect);
811+ tab->tabLocation = maxLocation > 0.0 ? tab->tabOffset / maxLocation : 0.0;
812+
813+ if (fTabList.CountItems() == 1)
814+ fTitleBarRect = tabRect;
815+
816+ _CalculateTabsRegion();
817+
818+ // redraw new rect as well
819+ rect = tabRect;
820+ rect.bottom++;
821+ if (updateRegion != NULL)
822+ updateRegion->Include(rect);
823+
824+ return true;
825+}
826+
827+
828+bool
829+TabDecorator::_SetSettings(const BMessage& settings, BRegion* updateRegion)
830+{
831+ float tabLocation;
832+ bool modified = false;
833+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
834+ if (settings.FindFloat("tab location", i, &tabLocation) != B_OK)
835+ return false;
836+ modified |= SetTabLocation(i, tabLocation, updateRegion);
837+ }
838+ return modified;
839+}
840+
841+
842+bool
843+TabDecorator::_AddTab(DesktopSettings& settings, int32 index,
844+ BRegion* updateRegion)
845+{
846+ _UpdateFont(settings);
847+
848+ _DoLayout();
849+ _DoOutlineLayout();
850+
851+ if (updateRegion != NULL)
852+ updateRegion->Include(fTitleBarRect);
853+ return true;
854+}
855+
856+
857+bool
858+TabDecorator::_RemoveTab(int32 index, BRegion* updateRegion)
859+{
860+ BRect oldRect = TabRect(index) | TabRect(CountTabs() - 1);
861+ // Get a rect of all the tabs to the right - they will all be moved
862+
863+ _DoLayout();
864+ _DoOutlineLayout();
865+
866+ if (updateRegion != NULL) {
867+ updateRegion->Include(oldRect);
868+ updateRegion->Include(fTitleBarRect);
869+ }
870+ return true;
871+}
872+
873+
874+bool
875+TabDecorator::_MoveTab(int32 from, int32 to, bool isMoving,
876+ BRegion* updateRegion)
877+{
878+ Decorator::Tab* toTab = _TabAt(to);
879+ if (toTab == NULL)
880+ return false;
881+
882+ if (from < to) {
883+ fOldMovingTab.OffsetBy(toTab->tabRect.Width(), 0);
884+ toTab->tabRect.OffsetBy(-fOldMovingTab.Width(), 0);
885+ } else {
886+ fOldMovingTab.OffsetBy(-toTab->tabRect.Width(), 0);
887+ toTab->tabRect.OffsetBy(fOldMovingTab.Width(), 0);
888+ }
889+
890+ toTab->tabOffset = uint32(toTab->tabRect.left - fLeftBorder.left);
891+ _LayoutTabItems(toTab, toTab->tabRect);
892+
893+ _CalculateTabsRegion();
894+
895+ if (updateRegion != NULL)
896+ updateRegion->Include(fTitleBarRect);
897+ return true;
898+}
899+
900+
901+void
902+TabDecorator::_GetFootprint(BRegion *region)
903+{
904+ STRACE(("TabDecorator: GetFootprint\n"));
905+
906+ // This function calculates the decorator's footprint in coordinates
907+ // relative to the view. This is most often used to set a Window
908+ // object's visible region.
909+
910+ if (region == NULL)
911+ return;
912+
913+ if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
914+ return;
915+
916+ region->Include(fTopBorder);
917+ region->Include(fLeftBorder);
918+ region->Include(fRightBorder);
919+ region->Include(fBottomBorder);
920+
921+ if (fTopTab->look == B_BORDERED_WINDOW_LOOK)
922+ return;
923+
924+ region->Include(&fTabsRegion);
925+
926+ if (fTopTab->look == B_DOCUMENT_WINDOW_LOOK) {
927+ // include the rectangular resize knob on the bottom right
928+ float knobSize = fResizeKnobSize - fBorderWidth;
929+ region->Include(BRect(fFrame.right - knobSize, fFrame.bottom - knobSize,
930+ fFrame.right, fFrame.bottom));
931+ }
932+}
933+
934+
935+void
936+TabDecorator::_DrawButtons(Decorator::Tab* tab, const BRect& invalid)
937+{
938+ STRACE(("TabDecorator: _DrawButtons\n"));
939+
940+ // Draw the buttons if we're supposed to
941+ if (!(tab->flags & B_NOT_CLOSABLE) && invalid.Intersects(tab->closeRect))
942+ _DrawClose(tab, false, tab->closeRect);
943+ if (!(tab->flags & B_NOT_ZOOMABLE) && invalid.Intersects(tab->zoomRect))
944+ _DrawZoom(tab, false, tab->zoomRect);
945+}
946+
947+
948+void
949+TabDecorator::_UpdateFont(DesktopSettings& settings)
950+{
951+ ServerFont font;
952+ if (fTopTab->look == B_FLOATING_WINDOW_LOOK
953+ || fTopTab->look == kLeftTitledWindowLook) {
954+ settings.GetDefaultPlainFont(font);
955+ if (fTopTab->look == kLeftTitledWindowLook)
956+ font.SetRotation(90.0f);
957+ } else
958+ settings.GetDefaultBoldFont(font);
959+
960+ font.SetFlags(B_FORCE_ANTIALIASING);
961+ font.SetSpacing(B_STRING_SPACING);
962+ fDrawState.SetFont(font);
963+}
964+
965+
966+void
967+TabDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset,
968+ float* _size, float* _inset) const
969+{
970+ float tabSize = fTopTab->look == kLeftTitledWindowLook ?
971+ tabRect.Width() : tabRect.Height();
972+
973+ bool smallTab = fTopTab->look == B_FLOATING_WINDOW_LOOK
974+ || fTopTab->look == kLeftTitledWindowLook;
975+
976+ *_offset = smallTab ? floorf(fDrawState.Font().Size() / 2.6)
977+ : floorf(fDrawState.Font().Size() / 2.3);
978+ *_inset = smallTab ? floorf(fDrawState.Font().Size() / 5.0)
979+ : floorf(fDrawState.Font().Size() / 6.0);
980+
981+ // "+ 2" so that the rects are centered within the solid area
982+ // (without the 2 pixels for the top border)
983+ *_size = tabSize - 2 * *_offset + *_inset;
984+}
985+
986+
987+void
988+TabDecorator::_LayoutTabItems(Decorator::Tab* _tab, const BRect& tabRect)
989+{
990+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
991+
992+ float offset;
993+ float size;
994+ float inset;
995+ _GetButtonSizeAndOffset(tabRect, &offset, &size, &inset);
996+
997+ // default textOffset
998+ tab->textOffset = _DefaultTextOffset();
999+
1000+ BRect& closeRect = tab->closeRect;
1001+ BRect& zoomRect = tab->zoomRect;
1002+
1003+ // calulate close rect based on the tab rectangle
1004+ if (tab->look != kLeftTitledWindowLook) {
1005+ closeRect.Set(tabRect.left + offset, tabRect.top + offset,
1006+ tabRect.left + offset + size, tabRect.top + offset + size);
1007+
1008+ zoomRect.Set(tabRect.right - offset - size, tabRect.top + offset,
1009+ tabRect.right - offset, tabRect.top + offset + size);
1010+
1011+ // hidden buttons have no width
1012+ if ((tab->flags & B_NOT_CLOSABLE) != 0)
1013+ closeRect.right = closeRect.left - offset;
1014+ if ((tab->flags & B_NOT_ZOOMABLE) != 0)
1015+ zoomRect.left = zoomRect.right + offset;
1016+ } else {
1017+ closeRect.Set(tabRect.left + offset, tabRect.top + offset,
1018+ tabRect.left + offset + size, tabRect.top + offset + size);
1019+
1020+ zoomRect.Set(tabRect.left + offset, tabRect.bottom - offset - size,
1021+ tabRect.left + size + offset, tabRect.bottom - offset);
1022+
1023+ // hidden buttons have no height
1024+ if ((tab->flags & B_NOT_CLOSABLE) != 0)
1025+ closeRect.bottom = closeRect.top - offset;
1026+ if ((tab->flags & B_NOT_ZOOMABLE) != 0)
1027+ zoomRect.top = zoomRect.bottom + offset;
1028+ }
1029+
1030+ // calculate room for title
1031+ // TODO: the +2 is there because the title often appeared
1032+ // truncated for no apparent reason - OTOH the title does
1033+ // also not appear perfectly in the middle
1034+ if (tab->look != kLeftTitledWindowLook)
1035+ size = (zoomRect.left - closeRect.right) - tab->textOffset * 2 + inset;
1036+ else
1037+ size = (zoomRect.top - closeRect.bottom) - tab->textOffset * 2 + inset;
1038+
1039+ bool stackMode = fTabList.CountItems() > 1;
1040+ if (stackMode && IsFocus(tab) == false) {
1041+ zoomRect.Set(0, 0, 0, 0);
1042+ size = (tab->tabRect.right - closeRect.right) - tab->textOffset * 2
1043+ + inset;
1044+ }
1045+ uint8 truncateMode = B_TRUNCATE_MIDDLE;
1046+ if (stackMode) {
1047+ if (tab->tabRect.Width() < 100)
1048+ truncateMode = B_TRUNCATE_END;
1049+ float titleWidth = fDrawState.Font().StringWidth(Title(tab),
1050+ BString(Title(tab)).Length());
1051+ if (size < titleWidth) {
1052+ float oldTextOffset = tab->textOffset;
1053+ tab->textOffset -= (titleWidth - size) / 2;
1054+ const float kMinTextOffset = 5.;
1055+ if (tab->textOffset < kMinTextOffset)
1056+ tab->textOffset = kMinTextOffset;
1057+ size += oldTextOffset * 2;
1058+ size -= tab->textOffset * 2;
1059+ }
1060+ }
1061+ tab->truncatedTitle = Title(tab);
1062+ fDrawState.Font().TruncateString(&tab->truncatedTitle, truncateMode, size);
1063+ tab->truncatedTitleLength = tab->truncatedTitle.Length();
1064+}
1065+
1066+
1067+float
1068+TabDecorator::_DefaultTextOffset() const
1069+{
1070+ if (fTopTab->look == B_FLOATING_WINDOW_LOOK
1071+ || fTopTab->look == kLeftTitledWindowLook)
1072+ return int32(fBorderWidth * 3.4f);
1073+ return int32(fBorderWidth * 3.6f);
1074+}
1075+
1076+
1077+float
1078+TabDecorator::_SingleTabOffsetAndSize(float& tabSize)
1079+{
1080+ float maxLocation;
1081+ if (fTopTab->look != kLeftTitledWindowLook) {
1082+ tabSize = fRightBorder.right - fLeftBorder.left;
1083+ } else {
1084+ tabSize = fBottomBorder.bottom - fTopBorder.top;
1085+ }
1086+ Decorator::Tab* tab = _TabAt(0);
1087+ maxLocation = tabSize - tab->maxTabSize;
1088+ if (maxLocation < 0)
1089+ maxLocation = 0;
1090+
1091+ return floorf(tab->tabLocation * maxLocation);
1092+}
1093+
1094+
1095+void
1096+TabDecorator::_CalculateTabsRegion()
1097+{
1098+ fTabsRegion.MakeEmpty();
1099+ for (int32 i = 0; i < fTabList.CountItems(); i++)
1100+ fTabsRegion.Include(fTabList.ItemAt(i)->tabRect);
1101+}
+160,
-0
1@@ -0,0 +1,160 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * Ryan Leavengood, leavengood@gmail.com
10+ * Philippe Saint-Pierre, stpere@gmail.com
11+ * John Scipione, jscipione@gmail.com
12+ * Ingo Weinhold, ingo_weinhold@gmx.de
13+ * Clemens Zeidler, haiku@clemens-zeidler.de
14+ * Joseph Groover, looncraz@looncraz.net
15+ * Jacob Secunda, secundja@gmail.com
16+ */
17+#ifndef TAB_DECORATOR_H
18+#define TAB_DECORATOR_H
19+
20+
21+#include <Region.h>
22+
23+#include "Decorator.h"
24+
25+
26+class Desktop;
27+
28+
29+class TabDecorator: public Decorator {
30+public:
31+ TabDecorator(DesktopSettings& settings,
32+ BRect frame, Desktop* desktop);
33+ virtual ~TabDecorator();
34+
35+protected:
36+ enum {
37+ COLOR_TAB_FRAME_LIGHT = 0,
38+ COLOR_TAB_FRAME_DARK = 1,
39+ COLOR_TAB = 2,
40+ COLOR_TAB_LIGHT = 3,
41+ COLOR_TAB_BEVEL = 4,
42+ COLOR_TAB_SHADOW = 5,
43+ COLOR_TAB_TEXT = 6
44+ };
45+
46+ enum {
47+ COLOR_BUTTON = 0,
48+ COLOR_BUTTON_LIGHT = 1
49+ };
50+
51+ enum Component {
52+ COMPONENT_TAB,
53+
54+ COMPONENT_CLOSE_BUTTON,
55+ COMPONENT_ZOOM_BUTTON,
56+
57+ COMPONENT_LEFT_BORDER,
58+ COMPONENT_RIGHT_BORDER,
59+ COMPONENT_TOP_BORDER,
60+ COMPONENT_BOTTOM_BORDER,
61+
62+ COMPONENT_RESIZE_CORNER
63+ };
64+
65+ typedef rgb_color ComponentColors[7];
66+
67+public:
68+ virtual void Draw(BRect updateRect);
69+ virtual void Draw();
70+
71+ virtual Region RegionAt(BPoint where, int32& tab) const;
72+
73+ virtual bool SetRegionHighlight(Region region,
74+ uint8 highlight, BRegion* dirty,
75+ int32 tab = -1);
76+
77+ virtual void UpdateColors(DesktopSettings& settings);
78+
79+protected:
80+ virtual void _DoLayout();
81+ virtual void _DoOutlineLayout();
82+ virtual void _DoTabLayout();
83+ void _DistributeTabSize(float delta);
84+
85+ virtual void _DrawFrame(BRect rect) = 0;
86+ virtual void _DrawOutlineFrame(BRect rect);
87+ virtual void _DrawTab(Decorator::Tab* tab, BRect r) = 0;
88+
89+ virtual void _DrawButtons(Decorator::Tab* tab,
90+ const BRect& invalid);
91+ virtual void _DrawClose(Decorator::Tab* tab, bool direct,
92+ BRect r) = 0;
93+ virtual void _DrawTitle(Decorator::Tab* tab, BRect r) = 0;
94+ virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
95+ BRect r) = 0;
96+
97+ virtual void _SetTitle(Decorator::Tab* tab,
98+ const char* string,
99+ BRegion* updateRegion = NULL);
100+
101+ virtual void _MoveBy(BPoint offset);
102+ virtual void _ResizeBy(BPoint offset, BRegion* dirty);
103+
104+ virtual void _SetFocus(Decorator::Tab* tab);
105+ virtual bool _SetTabLocation(Decorator::Tab* tab,
106+ float location, bool isShifting,
107+ BRegion* updateRegion = NULL);
108+
109+ virtual bool _SetSettings(const BMessage& settings,
110+ BRegion* updateRegion = NULL);
111+
112+ virtual bool _AddTab(DesktopSettings& settings,
113+ int32 index = -1,
114+ BRegion* updateRegion = NULL);
115+ virtual bool _RemoveTab(int32 index,
116+ BRegion* updateRegion = NULL);
117+ virtual bool _MoveTab(int32 from, int32 to, bool isMoving,
118+ BRegion* updateRegion = NULL);
119+
120+ virtual void _GetFootprint(BRegion* region);
121+
122+ virtual void _GetButtonSizeAndOffset(const BRect& tabRect,
123+ float* offset, float* size,
124+ float* inset) const;
125+
126+ virtual void _UpdateFont(DesktopSettings& settings);
127+
128+private:
129+ void _LayoutTabItems(Decorator::Tab* tab,
130+ const BRect& tabRect);
131+
132+protected:
133+ inline float _DefaultTextOffset() const;
134+ inline float _SingleTabOffsetAndSize(float& tabSize);
135+
136+ void _CalculateTabsRegion();
137+
138+protected:
139+ BRegion fTabsRegion;
140+ BRect fOldMovingTab;
141+ float fBorderResizeLength, fResizeKnobSize;
142+
143+ rgb_color fFocusFrameColor;
144+
145+ rgb_color fFocusTabColor;
146+ rgb_color fFocusTabColorLight;
147+ rgb_color fFocusTabColorBevel;
148+ rgb_color fFocusTabColorShadow;
149+ rgb_color fFocusTextColor;
150+
151+ rgb_color fNonFocusFrameColor;
152+
153+ rgb_color fNonFocusTabColor;
154+ rgb_color fNonFocusTabColorLight;
155+ rgb_color fNonFocusTabColorBevel;
156+ rgb_color fNonFocusTabColorShadow;
157+ rgb_color fNonFocusTextColor;
158+};
159+
160+
161+#endif // TAB_DECORATOR_H
+62,
-0
1@@ -0,0 +1,62 @@
2+/*
3+ * Copyright 2010, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Clemens Zeidler <haiku@clemens-zeidler.de>
8+ */
9+
10+
11+#include "WindowBehaviour.h"
12+
13+
14+WindowBehaviour::WindowBehaviour()
15+ :
16+ fIsResizing(false),
17+ fIsDragging(false)
18+{
19+}
20+
21+
22+WindowBehaviour::~WindowBehaviour()
23+{
24+}
25+
26+
27+void
28+WindowBehaviour::ModifiersChanged(int32 modifiers)
29+{
30+}
31+
32+
33+bool
34+WindowBehaviour::AlterDeltaForSnap(Window* window, BPoint& delta, bigtime_t now)
35+{
36+ return false;
37+}
38+
39+
40+/*! \fn WindowBehaviour::MouseDown()
41+ \brief Handles a mouse-down message for the window.
42+
43+ Note that values passed and returned for the hit regions are only meaningful
44+ to the WindowBehavior subclass, save for the value 0, which is refers to an
45+ invalid region.
46+
47+ \param message The message.
48+ \param where The point where the mouse click happened.
49+ \param lastHitRegion The hit region of the previous click.
50+ \param clickCount The number of subsequent, no longer than double-click
51+ interval separated clicks that have happened so far. This number doesn't
52+ necessarily match the value in the message. It has already been
53+ pre-processed in order to avoid erroneous multi-clicks (e.g. when a
54+ different button has been used or a different window was targeted). This
55+ is an in-out variable. The method can reset the value to 1, if it
56+ doesn't want this event handled as a multi-click. Returning a different
57+ click hit region will also make the caller reset the click count.
58+ \param _hitRegion Set by the method to a value identifying the clicked
59+ decorator element. If not explicitly set, an invalid hit region (0) is
60+ assumed. Only needs to be set when returning \c true.
61+ \return \c true, if the event was a WindowBehaviour event and should be
62+ discarded.
63+*/
+52,
-0
1@@ -0,0 +1,52 @@
2+/*
3+ * Copyright 2010, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Clemens Zeidler <haiku@clemens-zeidler.de>
8+ */
9+#ifndef WINDOW_BEHAVIOUR_H
10+#define WINDOW_BEHAVIOUR_H
11+
12+
13+#include <Region.h>
14+
15+#include "Decorator.h"
16+
17+
18+class BMessage;
19+class ClickTarget;
20+class Window;
21+
22+
23+class WindowBehaviour {
24+public:
25+ WindowBehaviour();
26+ virtual ~WindowBehaviour();
27+
28+ virtual bool MouseDown(BMessage* message, BPoint where,
29+ int32 lastHitRegion, int32& clickCount,
30+ int32& _hitRegion) = 0;
31+ virtual void MouseUp(BMessage* message, BPoint where) = 0;
32+ virtual void MouseMoved(BMessage *message, BPoint where,
33+ bool isFake) = 0;
34+
35+ virtual void ModifiersChanged(int32 modifiers);
36+
37+ bool IsDragging() const { return fIsDragging; }
38+ bool IsResizing() const { return fIsResizing; }
39+
40+protected:
41+ /*! The window is going to be moved by delta. This hook should be used to
42+ implement the magnetic screen border, i.e. alter the delta accordantly.
43+ \return true if delta has been modified. */
44+ virtual bool AlterDeltaForSnap(Window* window, BPoint& delta,
45+ bigtime_t now);
46+
47+protected:
48+ bool fIsResizing : 1;
49+ bool fIsDragging : 1;
50+};
51+
52+
53+#endif
1@@ -0,0 +1 @@
2+#include <../private/shared/AutoDeleter.h>
+194,
-0
1@@ -0,0 +1,194 @@
2+/*
3+ * Copyright 2005-2007, Ingo Weinhold, bonefish@users.sf.net.
4+ * All rights reserved. Distributed under the terms of the MIT License.
5+ */
6+#ifndef _AUTO_LOCKER_H
7+#define _AUTO_LOCKER_H
8+
9+
10+#include <stddef.h>
11+
12+
13+namespace BPrivate {
14+
15+// AutoLockerStandardLocking
16+template<typename Lockable>
17+class AutoLockerStandardLocking {
18+public:
19+ inline bool Lock(Lockable* lockable)
20+ {
21+ return lockable->Lock();
22+ }
23+
24+ inline void Unlock(Lockable* lockable)
25+ {
26+ lockable->Unlock();
27+ }
28+};
29+
30+// AutoLockerHandlerLocking
31+template<typename Lockable>
32+class AutoLockerHandlerLocking {
33+public:
34+ inline bool Lock(Lockable* lockable)
35+ {
36+ return lockable->LockLooper();
37+ }
38+
39+ inline void Unlock(Lockable* lockable)
40+ {
41+ lockable->UnlockLooper();
42+ }
43+};
44+
45+// AutoLockerReadLocking
46+template<typename Lockable>
47+class AutoLockerReadLocking {
48+public:
49+ inline bool Lock(Lockable* lockable)
50+ {
51+ return lockable->ReadLock();
52+ }
53+
54+ inline void Unlock(Lockable* lockable)
55+ {
56+ lockable->ReadUnlock();
57+ }
58+};
59+
60+// AutoLockerWriteLocking
61+template<typename Lockable>
62+class AutoLockerWriteLocking {
63+public:
64+ inline bool Lock(Lockable* lockable)
65+ {
66+ return lockable->WriteLock();
67+ }
68+
69+ inline void Unlock(Lockable* lockable)
70+ {
71+ lockable->WriteUnlock();
72+ }
73+};
74+
75+// AutoLocker
76+template<typename Lockable,
77+ typename Locking = AutoLockerStandardLocking<Lockable> >
78+class AutoLocker {
79+private:
80+ typedef AutoLocker<Lockable, Locking> ThisClass;
81+public:
82+ inline AutoLocker()
83+ :
84+ fLockable(NULL),
85+ fLocked(false)
86+ {
87+ }
88+
89+ inline AutoLocker(const Locking& locking)
90+ :
91+ fLockable(NULL),
92+ fLocking(locking),
93+ fLocked(false)
94+ {
95+ }
96+
97+ inline AutoLocker(Lockable* lockable, bool alreadyLocked = false,
98+ bool lockIfNotLocked = true)
99+ :
100+ fLockable(lockable),
101+ fLocked(fLockable && alreadyLocked)
102+ {
103+ if (!alreadyLocked && lockIfNotLocked)
104+ Lock();
105+ }
106+
107+ inline AutoLocker(Lockable& lockable, bool alreadyLocked = false,
108+ bool lockIfNotLocked = true)
109+ :
110+ fLockable(&lockable),
111+ fLocked(fLockable && alreadyLocked)
112+ {
113+ if (!alreadyLocked && lockIfNotLocked)
114+ Lock();
115+ }
116+
117+ inline ~AutoLocker()
118+ {
119+ Unlock();
120+ }
121+
122+ inline void SetTo(Lockable* lockable, bool alreadyLocked,
123+ bool lockIfNotLocked = true)
124+ {
125+ Unlock();
126+ fLockable = lockable;
127+ fLocked = (lockable && alreadyLocked);
128+ if (!alreadyLocked && lockIfNotLocked)
129+ Lock();
130+ }
131+
132+ inline void SetTo(Lockable& lockable, bool alreadyLocked,
133+ bool lockIfNotLocked = true)
134+ {
135+ SetTo(&lockable, alreadyLocked, lockIfNotLocked);
136+ }
137+
138+ inline void Unset()
139+ {
140+ Unlock();
141+ Detach();
142+ }
143+
144+ inline bool Lock()
145+ {
146+ if (fLockable && !fLocked)
147+ fLocked = fLocking.Lock(fLockable);
148+ return fLocked;
149+ }
150+
151+ inline void Unlock()
152+ {
153+ if (fLockable && fLocked) {
154+ fLocking.Unlock(fLockable);
155+ fLocked = false;
156+ }
157+ }
158+
159+ inline void Detach()
160+ {
161+ fLockable = NULL;
162+ fLocked = false;
163+ }
164+
165+ inline AutoLocker<Lockable, Locking>& operator=(Lockable* lockable)
166+ {
167+ SetTo(lockable);
168+ return *this;
169+ }
170+
171+ inline AutoLocker<Lockable, Locking>& operator=(Lockable& lockable)
172+ {
173+ SetTo(&lockable);
174+ return *this;
175+ }
176+
177+ inline bool IsLocked() const { return fLocked; }
178+
179+ inline operator bool() const { return fLocked; }
180+
181+protected:
182+ Lockable* fLockable;
183+ Locking fLocking;
184+ bool fLocked;
185+};
186+
187+
188+} // namespace BPrivate
189+
190+using ::BPrivate::AutoLocker;
191+using ::BPrivate::AutoLockerHandlerLocking;
192+using ::BPrivate::AutoLockerReadLocking;
193+using ::BPrivate::AutoLockerWriteLocking;
194+
195+#endif // _AUTO_LOCKER_H
1@@ -0,0 +1,37 @@
2+#ifndef BITMAP_DRAWING_ENGINE_H
3+#define BITMAP_DRAWING_ENGINE_H
4+
5+#include "DrawingEngine.h"
6+
7+#include <AutoDeleter.h>
8+#include <Referenceable.h>
9+#include <Region.h>
10+
11+class BitmapHWInterface;
12+class UtilityBitmap;
13+
14+class BitmapDrawingEngine : public DrawingEngine {
15+public:
16+ BitmapDrawingEngine(
17+ color_space colorSpace = B_RGB32);
18+virtual ~BitmapDrawingEngine();
19+
20+#if DEBUG
21+ virtual bool IsParallelAccessLocked() const;
22+#endif
23+ virtual bool IsExclusiveAccessLocked() const;
24+
25+ status_t SetSize(int32 newWidth, int32 newHeight);
26+ UtilityBitmap* ExportToBitmap(int32 width, int32 height,
27+ color_space space);
28+
29+private:
30+ color_space fColorSpace;
31+ ObjectDeleter<BitmapHWInterface>
32+ fHWInterface;
33+ BReference<UtilityBitmap>
34+ fBitmap;
35+ BRegion fClipping;
36+};
37+
38+#endif // BITMAP_DRAWING_ENGINE_H
1@@ -0,0 +1,111 @@
2+/*
3+ * Copyright 2006-2013, Haiku, Inc. All Rights Reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef CLIENT_MEMORY_ALLOCATOR_H
10+#define CLIENT_MEMORY_ALLOCATOR_H
11+
12+
13+#include <Locker.h>
14+#include <Referenceable.h>
15+
16+#include <util/DoublyLinkedList.h>
17+
18+
19+class ServerApp;
20+struct chunk;
21+struct block;
22+
23+struct chunk : DoublyLinkedListLinkImpl<struct chunk> {
24+ area_id area;
25+ uint8* base;
26+ size_t size;
27+};
28+
29+struct block : DoublyLinkedListLinkImpl<struct block> {
30+ struct chunk* chunk;
31+ uint8* base;
32+ size_t size;
33+};
34+
35+typedef DoublyLinkedList<block> block_list;
36+typedef DoublyLinkedList<chunk> chunk_list;
37+
38+
39+class ClientMemoryAllocator : public BReferenceable {
40+public:
41+ ClientMemoryAllocator(ServerApp* application);
42+ ~ClientMemoryAllocator();
43+
44+ void* Allocate(size_t size, block** _address,
45+ bool& newArea);
46+ void Free(block* cookie);
47+
48+ void Detach();
49+
50+ void Dump();
51+
52+private:
53+ struct block* _AllocateChunk(size_t size, bool& newArea);
54+
55+private:
56+ ServerApp* fApplication;
57+ BLocker fLock;
58+ chunk_list fChunks;
59+ block_list fFreeBlocks;
60+};
61+
62+
63+class AreaMemory {
64+public:
65+ virtual ~AreaMemory() {}
66+
67+ virtual area_id Area() = 0;
68+ virtual uint8* Address() = 0;
69+ virtual uint32 AreaOffset() = 0;
70+};
71+
72+
73+class ClientMemory : public AreaMemory {
74+public:
75+ ClientMemory();
76+
77+ virtual ~ClientMemory();
78+
79+ void* Allocate(ClientMemoryAllocator* allocator,
80+ size_t size, bool& newArea);
81+
82+ virtual area_id Area();
83+ virtual uint8* Address();
84+ virtual uint32 AreaOffset();
85+
86+private:
87+ BReference<ClientMemoryAllocator>
88+ fAllocator;
89+ block* fBlock;
90+};
91+
92+
93+/*! Just clones an existing area. */
94+class ClonedAreaMemory : public AreaMemory{
95+public:
96+ ClonedAreaMemory();
97+ virtual ~ClonedAreaMemory();
98+
99+ void* Clone(area_id area, uint32 offset);
100+
101+ virtual area_id Area();
102+ virtual uint8* Address();
103+ virtual uint32 AreaOffset();
104+
105+private:
106+ area_id fClonedArea;
107+ uint32 fOffset;
108+ uint8* fBase;
109+};
110+
111+
112+#endif /* CLIENT_MEMORY_ALLOCATOR_H */
+100,
-0
1@@ -0,0 +1,100 @@
2+/*
3+ * Copyright 2001-2010, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ */
9+#ifndef CURSOR_MANAGER_H
10+#define CURSOR_MANAGER_H
11+
12+
13+#include <List.h>
14+#include <Locker.h>
15+
16+#include <TokenSpace.h>
17+
18+#include "CursorSet.h"
19+
20+using BPrivate::BTokenSpace;
21+class ServerCursor;
22+
23+
24+/*!
25+ \class CursorManager CursorManager.h
26+ \brief Handles almost all cursor management functions for the system
27+
28+ The Cursor manager provides system cursor support, previous unseen on
29+ any BeOS platform. It also provides tokens for BCursors and frees all
30+ of an application's cursors whenever an application closes.
31+*/
32+class CursorManager : public BLocker {
33+public:
34+ CursorManager();
35+ ~CursorManager();
36+
37+ ServerCursor* CreateCursor(team_id clientTeam,
38+ const uint8* cursorData);
39+ ServerCursor* CreateCursor(team_id clientTeam,
40+ BRect r, color_space format, int32 flags,
41+ BPoint hotspot, int32 bytesPerRow = -1);
42+
43+ int32 AddCursor(ServerCursor* cursor,
44+ int32 token = -1);
45+ void DeleteCursors(team_id team);
46+
47+ bool RemoveCursor(ServerCursor* cursor);
48+
49+ void SetCursorSet(const char* path);
50+ ServerCursor* GetCursor(BCursorID which);
51+
52+ ServerCursor* FindCursor(int32 token);
53+
54+private:
55+ void _InitCursor(ServerCursor*& cursorMember,
56+ const uint8* cursorBits, BCursorID id,
57+ const BPoint& hotSpot = B_ORIGIN);
58+ void _LoadCursor(ServerCursor*& cursorMember,
59+ const CursorSet& set, BCursorID id);
60+ ServerCursor* _FindCursor(team_id cientTeam,
61+ const uint8* cursorData);
62+ void _RemoveCursor(ServerCursor* cursor);
63+
64+private:
65+ BList fCursorList;
66+ BTokenSpace fTokenSpace;
67+
68+ // System cursor members
69+ ServerCursor* fCursorSystemDefault;
70+
71+ ServerCursor* fCursorContextMenu;
72+ ServerCursor* fCursorCopy;
73+ ServerCursor* fCursorCreateLink;
74+ ServerCursor* fCursorCrossHair;
75+ ServerCursor* fCursorFollowLink;
76+ ServerCursor* fCursorGrab;
77+ ServerCursor* fCursorGrabbing;
78+ ServerCursor* fCursorHelp;
79+ ServerCursor* fCursorIBeam;
80+ ServerCursor* fCursorIBeamHorizontal;
81+ ServerCursor* fCursorMove;
82+ ServerCursor* fCursorNoCursor;
83+ ServerCursor* fCursorNotAllowed;
84+ ServerCursor* fCursorProgress;
85+ ServerCursor* fCursorResizeEast;
86+ ServerCursor* fCursorResizeEastWest;
87+ ServerCursor* fCursorResizeNorth;
88+ ServerCursor* fCursorResizeNorthEast;
89+ ServerCursor* fCursorResizeNorthEastSouthWest;
90+ ServerCursor* fCursorResizeNorthSouth;
91+ ServerCursor* fCursorResizeNorthWest;
92+ ServerCursor* fCursorResizeNorthWestSouthEast;
93+ ServerCursor* fCursorResizeSouth;
94+ ServerCursor* fCursorResizeSouthEast;
95+ ServerCursor* fCursorResizeSouthWest;
96+ ServerCursor* fCursorResizeWest;
97+ ServerCursor* fCursorZoomIn;
98+ ServerCursor* fCursorZoomOut;
99+};
100+
101+#endif // CURSOR_MANAGER_H
+43,
-0
1@@ -0,0 +1,43 @@
2+/*
3+ * Copyright 2001-2006, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ */
9+#ifndef CURSOR_SET_H
10+#define CURSOR_SET_H
11+
12+
13+#include <Bitmap.h>
14+#include <Cursor.h>
15+#include <Message.h>
16+
17+#include <ServerProtocol.h>
18+
19+class ServerCursor;
20+
21+
22+/*!
23+ \brief Class to manage system cursor sets
24+*/
25+class CursorSet : public BMessage {
26+ public:
27+ CursorSet(const char *name);
28+
29+ status_t Save(const char *path,int32 saveflags=0);
30+ status_t Load(const char *path);
31+ status_t AddCursor(BCursorID which,const BBitmap *cursor, const BPoint &hotspot);
32+ status_t AddCursor(BCursorID which, uint8 *data);
33+ void RemoveCursor(BCursorID which);
34+ status_t FindCursor(BCursorID which, BBitmap **cursor, BPoint *hotspot);
35+ status_t FindCursor(BCursorID which, ServerCursor **cursor) const;
36+ void SetName(const char *name);
37+ const char *GetName();
38+
39+ private:
40+ const char *_CursorWhichToString(BCursorID which) const;
41+ BBitmap *_CursorDataToBitmap(uint8 *data);
42+};
43+
44+#endif // CURSOR_SET_H
+141,
-0
1@@ -0,0 +1,141 @@
2+/*
3+ * Public domain source code.
4+ *
5+ * Author:
6+ * Joseph "looncraz" Groover <looncraz@satx.rr.com>
7+ */
8+#ifndef DECOR_INFO_H
9+#define DECOR_INFO_H
10+
11+
12+#include <Directory.h>
13+#include <Entry.h>
14+#include <Locker.h>
15+#include <ObjectList.h>
16+#include <String.h>
17+
18+
19+class BWindow;
20+
21+
22+namespace BPrivate {
23+
24+
25+// NOTE: DecorInfo itself is not thread-safe
26+class DecorInfo {
27+public:
28+ DecorInfo();
29+ DecorInfo(const BString& path);
30+ DecorInfo(const entry_ref& ref);
31+ ~DecorInfo();
32+
33+ status_t SetTo(const entry_ref& ref);
34+ status_t SetTo(BString path);
35+ status_t InitCheck() const;
36+ void Unset();
37+
38+ bool IsDefault() const;
39+
40+ BString Path() const;
41+ // Returns "Default" for the default decorator
42+
43+ const entry_ref* Ref() const;
44+ // Returns NULL if virtual (default) or InitCheck() != B_OK
45+ // The ref returned may NOT be the same as the one given to
46+ // SetTo or the constructor - we may have traversed a Symlink!
47+
48+ BString Name() const;
49+ BString ShortcutName() const;
50+
51+ BString Authors() const;
52+ BString ShortDescription() const;
53+ BString LongDescription() const;
54+ BString LicenseURL() const;
55+ BString LicenseName() const;
56+ BString SupportURL() const;
57+
58+ float Version() const;
59+ time_t ModificationTime() const;
60+
61+ bool CheckForChanges(bool &deleted);
62+
63+private:
64+ void _Init(bool is_update = false);
65+
66+private:
67+ entry_ref fRef;
68+
69+ BString fPath;
70+ BString fName;
71+ BString fAuthors;
72+ BString fShortDescription;
73+ BString fLongDescription;
74+ BString fLicenseURL;
75+ BString fLicenseName;
76+ BString fSupportURL;
77+
78+ float fVersion;
79+
80+ time_t fModificationTime;
81+
82+ status_t fInitStatus;
83+};
84+
85+
86+class DecorInfoUtility {
87+public:
88+ DecorInfoUtility(bool scanNow = true);
89+ // NOTE: When scanNow is passed false,
90+ // scanning will be performed lazily, such
91+ // as in CountDecorators() and other
92+ // methods.
93+
94+ ~DecorInfoUtility();
95+
96+ status_t ScanDecorators();
97+ // Can also be used to rescan for changes.
98+ // Warning: potentially destructive as we
99+ // will remove all DecorInfo objects which
100+ // no longer have a file system cousin.
101+ // TODO: Would a call-back mechanism be
102+ // worthwhile here?
103+
104+ int32 CountDecorators();
105+
106+ DecorInfo* DecoratorAt(int32);
107+
108+ DecorInfo* FindDecorator(const BString& string);
109+ // Checks for ref.name, path, fName, and
110+ // "Default," an empty-string returns the
111+ // current decorator NULL on match failure
112+
113+ DecorInfo* CurrentDecorator();
114+ DecorInfo* DefaultDecorator();
115+
116+ bool IsCurrentDecorator(DecorInfo* decor);
117+
118+ status_t SetDecorator(DecorInfo* decor);
119+ status_t SetDecorator(int32);
120+
121+ status_t Preview(DecorInfo* decor, BWindow* window);
122+
123+private:
124+ DecorInfo* _FindDecor(const BString& path);
125+
126+ status_t _ScanDecorators(BDirectory decoratorDirectory);
127+
128+private:
129+ BObjectList<DecorInfo> fList;
130+ BLocker fLock;
131+ bool fHasScanned;
132+};
133+
134+
135+} // namespace BPrivate
136+
137+
138+using BPrivate::DecorInfo;
139+using BPrivate::DecorInfoUtility;
140+
141+
142+#endif // DECOR_INFO_H
1@@ -0,0 +1,98 @@
2+/*
3+ * Copyright (c) 2001-2005, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Author:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Clemens Zeidler <haiku@clemens-zeidler.de>
9+ * Joseph Groover <looncraz@satx.rr.com>
10+ */
11+#ifndef DECOR_MANAGER_H
12+#define DECOR_MANAGER_H
13+
14+
15+#include <image.h>
16+#include <String.h>
17+#include <Locker.h>
18+#include <ObjectList.h>
19+#include <Entry.h>
20+#include <DecorInfo.h>
21+
22+#include "Decorator.h"
23+
24+class Desktop;
25+class DesktopListener;
26+class DrawingEngine;
27+class Window;
28+class WindowBehaviour;
29+
30+
31+typedef BObjectList<DesktopListener> DesktopListenerList;
32+
33+
34+// special name to test for use of non-fs-tied default decorator
35+// this just keeps things clean and simple is all
36+
37+class DecorAddOn {
38+public:
39+ DecorAddOn(image_id id, const char* name);
40+ virtual ~DecorAddOn();
41+
42+ virtual status_t InitCheck() const;
43+
44+ image_id ImageID() const { return fImageID; }
45+
46+ Decorator* AllocateDecorator(Desktop* desktop,
47+ DrawingEngine* engine, BRect rect,
48+ const char* title, window_look look,
49+ uint32 flags);
50+
51+ virtual WindowBehaviour* AllocateWindowBehaviour(Window* window);
52+
53+ virtual const DesktopListenerList& GetDesktopListeners();
54+
55+protected:
56+ virtual Decorator* _AllocateDecorator(DesktopSettings& settings,
57+ BRect rect, Desktop* desktop);
58+
59+ DesktopListenerList fDesktopListeners;
60+
61+private:
62+ image_id fImageID;
63+ BString fName;
64+};
65+
66+
67+class DecorManager {
68+public:
69+ DecorManager();
70+ ~DecorManager();
71+
72+ Decorator* AllocateDecorator(Window *window);
73+ WindowBehaviour* AllocateWindowBehaviour(Window *window);
74+ void CleanupForWindow(Window *window);
75+
76+ status_t PreviewDecorator(BString path, Window *window);
77+
78+ const DesktopListenerList& GetDesktopListeners();
79+
80+ BString GetCurrentDecorator() const;
81+ status_t SetDecorator(BString path, Desktop *desktop);
82+
83+private:
84+ DecorAddOn* _LoadDecor(BString path, status_t &error);
85+ bool _LoadSettingsFromDisk();
86+ bool _SaveSettingsToDisk();
87+
88+private:
89+ DecorAddOn fDefaultDecor;
90+ DecorAddOn* fCurrentDecor;
91+ DecorAddOn* fPreviewDecor;
92+
93+ Window* fPreviewWindow;
94+ BString fCurrentDecorPath;
95+};
96+
97+extern DecorManager gDecorManager;
98+
99+#endif /* DECOR_MANAGER_H */
+335,
-0
1@@ -0,0 +1,335 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * John Scipione, jscipione@gmail.com
10+ * Ingo Weinhold, ingo_weinhold@gmx.de
11+ * Clemens Zeidler, haiku@clemens-zeidler.de
12+ * Joseph Groover, looncraz@looncraz.net
13+ * Tri-Edge AI
14+ * Jacob Secunda, secundja@gmail.com
15+ */
16+#ifndef DECORATOR_H
17+#define DECORATOR_H
18+
19+
20+#include <Rect.h>
21+#include <Region.h>
22+#include <String.h>
23+#include <Window.h>
24+
25+#include "DrawState.h"
26+#include "MultiLocker.h"
27+
28+class Desktop;
29+class DesktopSettings;
30+class DrawingEngine;
31+class ServerBitmap;
32+class ServerFont;
33+class BRegion;
34+
35+
36+class Decorator {
37+public:
38+ struct Tab {
39+ Tab();
40+ virtual ~Tab() {}
41+
42+ BRect tabRect;
43+
44+ BRect zoomRect;
45+ BRect closeRect;
46+ BRect minimizeRect;
47+
48+ bool closePressed : 1;
49+ bool zoomPressed : 1;
50+ bool minimizePressed : 1;
51+
52+ window_look look;
53+ uint32 flags;
54+ bool isFocused : 1;
55+
56+ BString title;
57+
58+ uint32 tabOffset;
59+ float tabLocation;
60+ float textOffset;
61+
62+ BString truncatedTitle;
63+ int32 truncatedTitleLength;
64+
65+ bool buttonFocus : 1;
66+
67+ bool isHighlighted : 1;
68+
69+ float minTabSize;
70+ float maxTabSize;
71+
72+ ServerBitmap* closeBitmaps[4];
73+ ServerBitmap* minimizeBitmaps[4];
74+ ServerBitmap* zoomBitmaps[4];
75+ };
76+
77+ enum Region {
78+ REGION_NONE,
79+
80+ REGION_TAB,
81+
82+ REGION_CLOSE_BUTTON,
83+ REGION_ZOOM_BUTTON,
84+ REGION_MINIMIZE_BUTTON,
85+
86+ REGION_LEFT_BORDER,
87+ REGION_RIGHT_BORDER,
88+ REGION_TOP_BORDER,
89+ REGION_BOTTOM_BORDER,
90+
91+ REGION_LEFT_TOP_CORNER,
92+ REGION_LEFT_BOTTOM_CORNER,
93+ REGION_RIGHT_TOP_CORNER,
94+ REGION_RIGHT_BOTTOM_CORNER,
95+
96+ REGION_COUNT
97+ };
98+
99+ enum {
100+ HIGHLIGHT_NONE,
101+ HIGHLIGHT_RESIZE_BORDER,
102+
103+ HIGHLIGHT_USER_DEFINED
104+ };
105+
106+ Decorator(DesktopSettings& settings,
107+ BRect frame,
108+ Desktop* desktop);
109+ virtual ~Decorator();
110+
111+ virtual Decorator::Tab* AddTab(DesktopSettings& settings,
112+ const char* title, window_look look,
113+ uint32 flags, int32 index = -1,
114+ BRegion* updateRegion = NULL);
115+ virtual bool RemoveTab(int32 index,
116+ BRegion* updateRegion = NULL);
117+ virtual bool MoveTab(int32 from, int32 to, bool isMoving,
118+ BRegion* updateRegion = NULL);
119+
120+ virtual int32 TabAt(const BPoint& where) const;
121+ Decorator::Tab* TabAt(int32 index) const
122+ { return fTabList.ItemAt(index); }
123+ int32 CountTabs() const
124+ { return fTabList.CountItems(); }
125+ void SetTopTab(int32 tab);
126+
127+ void SetDrawingEngine(DrawingEngine *driver);
128+ inline DrawingEngine* GetDrawingEngine() const
129+ { return fDrawingEngine; }
130+
131+ void FontsChanged(DesktopSettings& settings,
132+ BRegion* updateRegion = NULL);
133+ void ColorsChanged(DesktopSettings& settings,
134+ BRegion* updateRegion = NULL);
135+
136+ virtual void UpdateColors(DesktopSettings& settings) = 0;
137+
138+ void SetLook(int32 tab, DesktopSettings& settings,
139+ window_look look,
140+ BRegion* updateRegion = NULL);
141+ void SetFlags(int32 tab, uint32 flags,
142+ BRegion* updateRegion = NULL);
143+
144+ window_look Look(int32 tab) const;
145+ uint32 Flags(int32 tab) const;
146+
147+ BRect BorderRect() const;
148+ BRect TitleBarRect() const;
149+ BRect TabRect(int32 tab) const;
150+ BRect TabRect(Decorator::Tab* tab) const;
151+
152+ void SetClose(int32 tab, bool pressed);
153+ void SetMinimize(int32 tab, bool pressed);
154+ void SetZoom(int32 tab, bool pressed);
155+
156+ const char* Title(int32 tab) const;
157+ const char* Title(Decorator::Tab* tab) const;
158+ void SetTitle(int32 tab, const char* string,
159+ BRegion* updateRegion = NULL);
160+
161+ void SetFocus(int32 tab, bool focussed);
162+ bool IsFocus(int32 tab) const;
163+ bool IsFocus(Decorator::Tab* tab) const;
164+
165+ virtual float TabLocation(int32 tab) const;
166+ bool SetTabLocation(int32 tab, float location,
167+ bool isShifting,
168+ BRegion* updateRegion = NULL);
169+ /*! \return true if tab location updated, false if out of
170+ bounds or unsupported */
171+
172+ virtual Region RegionAt(BPoint where, int32& tab) const;
173+
174+ const BRegion& GetFootprint();
175+ ::Desktop* GetDesktop();
176+
177+ void MoveBy(float x, float y);
178+ void MoveBy(BPoint offset);
179+ void ResizeBy(float x, float y, BRegion* dirty);
180+ void ResizeBy(BPoint offset, BRegion* dirty);
181+ void SetOutlinesDelta(BPoint delta, BRegion* dirty);
182+ bool IsOutlineResizing() const
183+ { return fOutlinesDelta != BPoint(0, 0); }
184+
185+ virtual bool SetRegionHighlight(Region region,
186+ uint8 highlight, BRegion* dirty,
187+ int32 tab = -1);
188+ inline uint8 RegionHighlight(Region region,
189+ int32 tab = -1) const;
190+
191+ bool SetSettings(const BMessage& settings,
192+ BRegion* updateRegion = NULL);
193+ virtual bool GetSettings(BMessage* settings) const;
194+
195+ virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
196+ int32* maxWidth, int32* maxHeight) const;
197+ virtual void ExtendDirtyRegion(Region region, BRegion& dirty);
198+
199+ virtual void Draw(BRect updateRect) = 0;
200+ virtual void Draw() = 0;
201+
202+ virtual void DrawTab(int32 tab);
203+ virtual void DrawTitle(int32 tab);
204+
205+ virtual void DrawClose(int32 tab);
206+ virtual void DrawMinimize(int32 tab);
207+ virtual void DrawZoom(int32 tab);
208+
209+ rgb_color UIColor(color_which which);
210+
211+ float BorderWidth();
212+ float TabHeight();
213+
214+protected:
215+ virtual Decorator::Tab* _AllocateNewTab();
216+
217+ virtual void _DoLayout() = 0;
218+ //! method for calculating layout for the decorator
219+ virtual void _DoOutlineLayout() = 0;
220+
221+ virtual void _DrawFrame(BRect rect) = 0;
222+ virtual void _DrawOutlineFrame(BRect rect) = 0;
223+ virtual void _DrawTabs(BRect rect);
224+
225+ virtual void _DrawTab(Decorator::Tab* tab, BRect rect) = 0;
226+ virtual void _DrawTitle(Decorator::Tab* tab,
227+ BRect rect) = 0;
228+
229+ virtual void _DrawButtons(Decorator::Tab* tab,
230+ const BRect& invalid) = 0;
231+ virtual void _DrawClose(Decorator::Tab* tab, bool direct,
232+ BRect rect) = 0;
233+ virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
234+ BRect rect) = 0;
235+ virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
236+ BRect rect) = 0;
237+
238+ virtual void _SetTitle(Decorator::Tab* tab,
239+ const char* string,
240+ BRegion* updateRegion = NULL) = 0;
241+ int32 _TitleWidth(Decorator::Tab* tab) const
242+ { return tab->title.CountChars(); }
243+
244+ virtual void _SetFocus(Decorator::Tab* tab);
245+ virtual bool _SetTabLocation(Decorator::Tab* tab,
246+ float location, bool isShifting,
247+ BRegion* updateRegion = NULL);
248+
249+ virtual Decorator::Tab* _TabAt(int32 index) const;
250+
251+ virtual void _FontsChanged(DesktopSettings& settings,
252+ BRegion* updateRegion = NULL);
253+ virtual void _UpdateFont(DesktopSettings& settings) = 0;
254+
255+ virtual void _SetLook(Decorator::Tab* tab,
256+ DesktopSettings& settings,
257+ window_look look,
258+ BRegion* updateRegion = NULL);
259+ virtual void _SetFlags(Decorator::Tab* tab, uint32 flags,
260+ BRegion* updateRegion = NULL);
261+
262+ virtual void _MoveBy(BPoint offset);
263+ virtual void _ResizeBy(BPoint offset, BRegion* dirty) = 0;
264+
265+ virtual void _MoveOutlineBy(BPoint offset);
266+ virtual void _ResizeOutlineBy(BPoint offset, BRegion* dirty);
267+ virtual void _SetOutlinesDelta(BPoint delta, BRegion* dirty);
268+
269+ virtual bool _SetSettings(const BMessage& settings,
270+ BRegion* updateRegion = NULL);
271+
272+ virtual bool _AddTab(DesktopSettings& settings,
273+ int32 index = -1,
274+ BRegion* updateRegion = NULL) = 0;
275+ virtual bool _RemoveTab(int32 index,
276+ BRegion* updateRegion = NULL) = 0;
277+ virtual bool _MoveTab(int32 from, int32 to, bool isMoving,
278+ BRegion* updateRegion = NULL) = 0;
279+
280+ virtual void _GetFootprint(BRegion* region);
281+ virtual void _GetOutlineFootprint(BRegion* region);
282+ void _InvalidateFootprint();
283+
284+ void _InvalidateBitmaps();
285+
286+protected:
287+ mutable MultiLocker fLocker;
288+
289+ DrawingEngine* fDrawingEngine;
290+ DrawState fDrawState;
291+
292+ BPoint fOutlinesDelta;
293+
294+ // Individual rects for handling window frame
295+ // rendering the proper way
296+ BRect fTitleBarRect;
297+ BRect fFrame;
298+ BRect fResizeRect;
299+ BRect fBorderRect;
300+ BRect fOutlineBorderRect;
301+
302+ BRect fLeftBorder;
303+ BRect fTopBorder;
304+ BRect fBottomBorder;
305+ BRect fRightBorder;
306+
307+ BRect fLeftOutlineBorder;
308+ BRect fTopOutlineBorder;
309+ BRect fBottomOutlineBorder;
310+ BRect fRightOutlineBorder;
311+
312+ int32 fBorderWidth;
313+ int32 fOutlineBorderWidth;
314+
315+ Decorator::Tab* fTopTab;
316+ BObjectList<Decorator::Tab> fTabList;
317+
318+private:
319+ Desktop* fDesktop;
320+ BRegion fFootprint;
321+ bool fFootprintValid : 1;
322+
323+ uint8 fRegionHighlights[REGION_COUNT - 1];
324+};
325+
326+
327+uint8
328+Decorator::RegionHighlight(Region region, int32 tab) const
329+{
330+ int32 index = (int32)region - 1;
331+ return index >= 0 && index < REGION_COUNT - 1
332+ ? fRegionHighlights[index] : 0;
333+}
334+
335+
336+#endif // DECORATOR_H
1@@ -0,0 +1,880 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * Ryan Leavengood, leavengood@gmail.com
10+ * Philippe Saint-Pierre, stpere@gmail.com
11+ * John Scipione, jscipione@gmail.com
12+ * Ingo Weinhold, ingo_weinhold@gmx.de
13+ * Clemens Zeidler, haiku@clemens-zeidler.de
14+ * Joseph Groover, looncraz@looncraz.net
15+ * Tri-Edge AI
16+ * Jacob Secunda, secundja@gmail.com
17+ */
18+
19+
20+/*! Default and fallback decorator for the app_server - the yellow tabs */
21+
22+
23+#include "DefaultDecorator.h"
24+
25+#include <algorithm>
26+#include <cmath>
27+#include <new>
28+#include <stdio.h>
29+
30+#include <Autolock.h>
31+#include <Debug.h>
32+#include <GradientLinear.h>
33+#include <Rect.h>
34+#include <Region.h>
35+#include <View.h>
36+
37+#include <WindowPrivate.h>
38+
39+#include "BitmapDrawingEngine.h"
40+#include "DesktopSettings.h"
41+#include "DrawingEngine.h"
42+#include "DrawState.h"
43+#include "FontManager.h"
44+#include "PatternHandler.h"
45+#include "ServerBitmap.h"
46+
47+
48+//#define DEBUG_DECORATOR
49+#ifdef DEBUG_DECORATOR
50+# define STRACE(x) printf x
51+#else
52+# define STRACE(x) ;
53+#endif
54+
55+
56+static inline uint8
57+blend_color_value(uint8 a, uint8 b, float position)
58+{
59+ int16 delta = (int16)b - a;
60+ int32 value = a + (int32)(position * delta);
61+ if (value > 255)
62+ return 255;
63+ if (value < 0)
64+ return 0;
65+
66+ return (uint8)value;
67+}
68+
69+
70+// #pragma mark -
71+
72+
73+// TODO: get rid of DesktopSettings here, and introduce private accessor
74+// methods to the Decorator base class
75+DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
76+ Desktop* desktop)
77+ :
78+ TabDecorator(settings, rect, desktop)
79+{
80+ // TODO: If the decorator was created with a frame too small, it should
81+ // resize itself!
82+
83+ STRACE(("DefaultDecorator:\n"));
84+ STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
85+ rect.left, rect.top, rect.right, rect.bottom));
86+}
87+
88+
89+DefaultDecorator::~DefaultDecorator()
90+{
91+ STRACE(("DefaultDecorator: ~DefaultDecorator()\n"));
92+}
93+
94+
95+// #pragma mark - Public methods
96+
97+
98+/*! Returns the frame colors for the specified decorator component.
99+
100+ The meaning of the color array elements depends on the specified component.
101+ For some components some array elements are unused.
102+
103+ \param component The component for which to return the frame colors.
104+ \param highlight The highlight set for the component.
105+ \param colors An array of colors to be initialized by the function.
106+*/
107+void
108+DefaultDecorator::GetComponentColors(Component component, uint8 highlight,
109+ ComponentColors _colors, Decorator::Tab* _tab)
110+{
111+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
112+ switch (component) {
113+ case COMPONENT_TAB:
114+ if (tab && tab->buttonFocus) {
115+ _colors[COLOR_TAB_FRAME_LIGHT]
116+ = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
117+ _colors[COLOR_TAB_FRAME_DARK]
118+ = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
119+ _colors[COLOR_TAB] = fFocusTabColor;
120+ _colors[COLOR_TAB_LIGHT] = fFocusTabColorLight;
121+ _colors[COLOR_TAB_BEVEL] = fFocusTabColorBevel;
122+ _colors[COLOR_TAB_SHADOW] = fFocusTabColorShadow;
123+ _colors[COLOR_TAB_TEXT] = fFocusTextColor;
124+ } else {
125+ _colors[COLOR_TAB_FRAME_LIGHT]
126+ = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
127+ _colors[COLOR_TAB_FRAME_DARK]
128+ = tint_color(fNonFocusFrameColor, B_DARKEN_3_TINT);
129+ _colors[COLOR_TAB] = fNonFocusTabColor;
130+ _colors[COLOR_TAB_LIGHT] = fNonFocusTabColorLight;
131+ _colors[COLOR_TAB_BEVEL] = fNonFocusTabColorBevel;
132+ _colors[COLOR_TAB_SHADOW] = fNonFocusTabColorShadow;
133+ _colors[COLOR_TAB_TEXT] = fNonFocusTextColor;
134+ }
135+ break;
136+
137+ case COMPONENT_CLOSE_BUTTON:
138+ case COMPONENT_ZOOM_BUTTON:
139+ if (tab && tab->buttonFocus) {
140+ _colors[COLOR_BUTTON] = fFocusTabColor;
141+ _colors[COLOR_BUTTON_LIGHT] = fFocusTabColorLight;
142+ } else {
143+ _colors[COLOR_BUTTON] = fNonFocusTabColor;
144+ _colors[COLOR_BUTTON_LIGHT] = fNonFocusTabColorLight;
145+ }
146+ break;
147+
148+ case COMPONENT_LEFT_BORDER:
149+ case COMPONENT_RIGHT_BORDER:
150+ case COMPONENT_TOP_BORDER:
151+ case COMPONENT_BOTTOM_BORDER:
152+ case COMPONENT_RESIZE_CORNER:
153+ default:
154+ if (tab && tab->buttonFocus) {
155+ _colors[0] = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
156+ _colors[1] = tint_color(fFocusFrameColor, B_LIGHTEN_2_TINT);
157+ _colors[2] = fFocusFrameColor;
158+ _colors[3] = tint_color(fFocusFrameColor,
159+ (B_DARKEN_1_TINT + B_NO_TINT) / 2);
160+ _colors[4] = tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
161+ _colors[5] = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
162+ } else {
163+ _colors[0] = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
164+ _colors[1] = tint_color(fNonFocusFrameColor, B_LIGHTEN_2_TINT);
165+ _colors[2] = fNonFocusFrameColor;
166+ _colors[3] = tint_color(fNonFocusFrameColor,
167+ (B_DARKEN_1_TINT + B_NO_TINT) / 2);
168+ _colors[4] = tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
169+ _colors[5] = tint_color(fNonFocusFrameColor, B_DARKEN_3_TINT);
170+ }
171+
172+ // for the resize-border highlight dye everything bluish.
173+ if (highlight == HIGHLIGHT_RESIZE_BORDER) {
174+ for (int32 i = 0; i < 6; i++) {
175+ _colors[i].red = std::max((int)_colors[i].red - 80, 0);
176+ _colors[i].green = std::max((int)_colors[i].green - 80, 0);
177+ _colors[i].blue = 255;
178+ }
179+ }
180+ break;
181+ }
182+}
183+
184+
185+void
186+DefaultDecorator::UpdateColors(DesktopSettings& settings)
187+{
188+ TabDecorator::UpdateColors(settings);
189+}
190+
191+
192+// #pragma mark - Protected methods
193+
194+
195+void
196+DefaultDecorator::_DrawFrame(BRect rect)
197+{
198+ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", rect.left, rect.top,
199+ rect.right, rect.bottom));
200+
201+ // NOTE: the DrawingEngine needs to be locked for the entire
202+ // time for the clipping to stay valid for this decorator
203+
204+ if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
205+ return;
206+
207+ if (fBorderWidth <= 0)
208+ return;
209+
210+ // TODO: While this works, it does not look so crisp at higher resolutions.
211+#define COLORS_INDEX(i, borderWidth, nominalLimit) int32((float(i) / float(borderWidth)) * nominalLimit)
212+
213+ // Draw the border frame
214+ BRect border = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
215+ switch ((int)fTopTab->look) {
216+ case B_TITLED_WINDOW_LOOK:
217+ case B_DOCUMENT_WINDOW_LOOK:
218+ case B_MODAL_WINDOW_LOOK:
219+ {
220+ // top
221+ if (rect.Intersects(fTopBorder)) {
222+ ComponentColors colors;
223+ _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
224+
225+ for (int8 i = 0; i < fBorderWidth; i++) {
226+ const int8 colorsIndex = COLORS_INDEX(i, fBorderWidth, 5);
227+ fDrawingEngine->StrokeLine(
228+ BPoint(border.left + i, border.top + i),
229+ BPoint(border.right - i, border.top + i),
230+ colors[colorsIndex]);
231+ }
232+ if (fTitleBarRect.IsValid()) {
233+ // grey along the bottom of the tab
234+ // (overwrites "white" from frame)
235+ const int overdraw = (int)ceilf(fBorderWidth / 5.0f);
236+ for (int i = 1; i <= overdraw; i++) {
237+ fDrawingEngine->StrokeLine(
238+ BPoint(fTitleBarRect.left + 2, fTitleBarRect.bottom + i),
239+ BPoint(fTitleBarRect.right - 2, fTitleBarRect.bottom + i),
240+ colors[2]);
241+ }
242+ }
243+ }
244+ // left
245+ if (rect.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
246+ ComponentColors colors;
247+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
248+
249+ for (int8 i = 0; i < fBorderWidth; i++) {
250+ const int8 colorsIndex = COLORS_INDEX(i, fBorderWidth, 5);
251+ fDrawingEngine->StrokeLine(
252+ BPoint(border.left + i, border.top + i),
253+ BPoint(border.left + i, border.bottom - i),
254+ colors[colorsIndex]);
255+ }
256+ }
257+ // bottom
258+ if (rect.Intersects(fBottomBorder)) {
259+ ComponentColors colors;
260+ _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
261+
262+ for (int8 i = 0; i < fBorderWidth; i++) {
263+ const int8 colorsIndex = COLORS_INDEX(i, fBorderWidth, 5);
264+ fDrawingEngine->StrokeLine(
265+ BPoint(border.left + i, border.bottom - i),
266+ BPoint(border.right - i, border.bottom - i),
267+ colors[(4 - colorsIndex) == 4 ? 5 : (4 - colorsIndex)]);
268+ }
269+ }
270+ // right
271+ if (rect.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
272+ ComponentColors colors;
273+ _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
274+
275+ for (int8 i = 0; i < fBorderWidth; i++) {
276+ const int8 colorsIndex = COLORS_INDEX(i, fBorderWidth, 5);
277+ fDrawingEngine->StrokeLine(
278+ BPoint(border.right - i, border.top + i),
279+ BPoint(border.right - i, border.bottom - i),
280+ colors[(4 - colorsIndex) == 4 ? 5 : (4 - colorsIndex)]);
281+ }
282+ }
283+ break;
284+ }
285+
286+ case B_FLOATING_WINDOW_LOOK:
287+ case kLeftTitledWindowLook:
288+ {
289+ // top
290+ if (rect.Intersects(fTopBorder)) {
291+ ComponentColors colors;
292+ _GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
293+
294+ for (int8 i = 0; i < fBorderWidth; i++) {
295+ const int8 colorsIndex = COLORS_INDEX(i, fBorderWidth, 3);
296+ fDrawingEngine->StrokeLine(
297+ BPoint(border.left + i, border.top + i),
298+ BPoint(border.right - i, border.top + i),
299+ colors[colorsIndex * 2]);
300+ }
301+ if (fTitleBarRect.IsValid() && fTopTab->look != kLeftTitledWindowLook) {
302+ // grey along the bottom of the tab
303+ // (overwrites "white" from frame)
304+ const int overdraw = (int)ceilf(fBorderWidth / 5.0f);
305+ for (int i = 1; i <= overdraw; i++) {
306+ fDrawingEngine->StrokeLine(
307+ BPoint(fTitleBarRect.left + 2, fTitleBarRect.bottom + i),
308+ BPoint(fTitleBarRect.right - 2, fTitleBarRect.bottom + i),
309+ colors[2]);
310+ }
311+ }
312+ }
313+ // left
314+ if (rect.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
315+ ComponentColors colors;
316+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
317+
318+ for (int8 i = 0; i < fBorderWidth; i++) {
319+ const int8 colorsIndex = COLORS_INDEX(i, fBorderWidth, 3);
320+ fDrawingEngine->StrokeLine(
321+ BPoint(border.left + i, border.top + i),
322+ BPoint(border.left + i, border.bottom - i),
323+ colors[colorsIndex * 2]);
324+ }
325+ if (fTopTab->look == kLeftTitledWindowLook
326+ && fTitleBarRect.IsValid()) {
327+ // grey along the right side of the tab
328+ // (overwrites "white" from frame)
329+ fDrawingEngine->StrokeLine(
330+ BPoint(fTitleBarRect.right + 1,
331+ fTitleBarRect.top + 2),
332+ BPoint(fTitleBarRect.right + 1,
333+ fTitleBarRect.bottom - 2), colors[2]);
334+ }
335+ }
336+ // bottom
337+ if (rect.Intersects(fBottomBorder)) {
338+ ComponentColors colors;
339+ _GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
340+
341+ for (int8 i = 0; i < fBorderWidth; i++) {
342+ const int8 colorsIndex = COLORS_INDEX(i, fBorderWidth, 3);
343+ fDrawingEngine->StrokeLine(
344+ BPoint(border.left + i, border.bottom - i),
345+ BPoint(border.right - i, border.bottom - i),
346+ colors[(2 - colorsIndex) == 2 ? 5 : (2 - colorsIndex) * 2]);
347+ }
348+ }
349+ // right
350+ if (rect.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
351+ ComponentColors colors;
352+ _GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
353+
354+ for (int8 i = 0; i < fBorderWidth; i++) {
355+ const int8 colorsIndex = COLORS_INDEX(i, fBorderWidth, 3);
356+ fDrawingEngine->StrokeLine(
357+ BPoint(border.right - i, border.top + i),
358+ BPoint(border.right - i, border.bottom - i),
359+ colors[(2 - colorsIndex) == 2 ? 5 : (2 - colorsIndex) * 2]);
360+ }
361+ }
362+ break;
363+ }
364+
365+ case B_BORDERED_WINDOW_LOOK:
366+ {
367+ // TODO: Draw the borders individually!
368+ ComponentColors colors;
369+ _GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
370+
371+ fDrawingEngine->StrokeRect(border, colors[5]);
372+ break;
373+ }
374+
375+ default:
376+ // don't draw a border frame
377+ break;
378+ }
379+
380+ // Draw the resize knob if we're supposed to
381+ if (!(fTopTab->flags & B_NOT_RESIZABLE)) {
382+ ComponentColors colors;
383+ _GetComponentColors(COMPONENT_RESIZE_CORNER, colors, fTopTab);
384+
385+ switch ((int)fTopTab->look) {
386+ case B_DOCUMENT_WINDOW_LOOK:
387+ {
388+ if (fOutlinesDelta.x != 0 || fOutlinesDelta.y != 0) {
389+ border.Set(fFrame.right - 13, fFrame.bottom - 13,
390+ fFrame.right + 3, fFrame.bottom + 3);
391+
392+ if (rect.Intersects(border))
393+ _DrawResizeKnob(border, false, colors);
394+ }
395+
396+ if (rect.Intersects(fResizeRect)) {
397+ _DrawResizeKnob(fResizeRect, fTopTab && IsFocus(fTopTab),
398+ colors);
399+ }
400+
401+ break;
402+ }
403+
404+ case B_TITLED_WINDOW_LOOK:
405+ case B_FLOATING_WINDOW_LOOK:
406+ case B_MODAL_WINDOW_LOOK:
407+ case kLeftTitledWindowLook:
408+ {
409+ if (!rect.Intersects(BRect(
410+ fRightBorder.right - fBorderResizeLength,
411+ fBottomBorder.bottom - fBorderResizeLength,
412+ fRightBorder.right - 1,
413+ fBottomBorder.bottom - 1)))
414+ break;
415+
416+ fDrawingEngine->StrokeLine(
417+ BPoint(fRightBorder.left,
418+ fBottomBorder.bottom - fBorderResizeLength),
419+ BPoint(fRightBorder.right - 1,
420+ fBottomBorder.bottom - fBorderResizeLength),
421+ colors[0]);
422+ fDrawingEngine->StrokeLine(
423+ BPoint(fRightBorder.right - fBorderResizeLength,
424+ fBottomBorder.top),
425+ BPoint(fRightBorder.right - fBorderResizeLength,
426+ fBottomBorder.bottom - 1),
427+ colors[0]);
428+ break;
429+ }
430+
431+ default:
432+ // don't draw resize corner
433+ break;
434+ }
435+ }
436+}
437+
438+
439+void
440+DefaultDecorator::_DrawResizeKnob(BRect rect, bool full,
441+ const ComponentColors& colors)
442+{
443+ float x = rect.right -= 3;
444+ float y = rect.bottom -= 3;
445+
446+ BGradientLinear gradient;
447+ gradient.SetStart(rect.LeftTop());
448+ gradient.SetEnd(rect.RightBottom());
449+ gradient.AddColor(colors[1], 0);
450+ gradient.AddColor(colors[2], 255);
451+
452+ fDrawingEngine->FillRect(rect, gradient);
453+
454+ BPoint offset1(rect.Width(), rect.Height()),
455+ offset2(rect.Width() - 1, rect.Height() - 1);
456+ fDrawingEngine->StrokeLine(BPoint(x, y) - offset1,
457+ BPoint(x - offset1.x, y - 2), colors[0]);
458+ fDrawingEngine->StrokeLine(BPoint(x, y) - offset2,
459+ BPoint(x - offset2.x, y - 1), colors[1]);
460+ fDrawingEngine->StrokeLine(BPoint(x, y) - offset1,
461+ BPoint(x - 2, y - offset1.y), colors[0]);
462+ fDrawingEngine->StrokeLine(BPoint(x, y) - offset2,
463+ BPoint(x - 1, y - offset2.y), colors[1]);
464+
465+ if (!full)
466+ return;
467+
468+ static const rgb_color kWhite
469+ = (rgb_color){ 255, 255, 255, 255 };
470+ for (int8 i = 1; i <= 4; i++) {
471+ for (int8 j = 1; j <= i; j++) {
472+ BPoint pt1(x - (3 * j) + 1, y - (3 * (5 - i)) + 1);
473+ BPoint pt2(x - (3 * j) + 2, y - (3 * (5 - i)) + 2);
474+ fDrawingEngine->StrokePoint(pt1, colors[0]);
475+ fDrawingEngine->StrokePoint(pt2, kWhite);
476+ }
477+ }
478+}
479+
480+
481+/*! \brief Actually draws the tab
482+
483+ This function is called when the tab itself needs drawn. Other items,
484+ like the window title or buttons, should not be drawn here.
485+
486+ \param tab The \a tab to update.
487+ \param rect The area of the \a tab to update.
488+*/
489+void
490+DefaultDecorator::_DrawTab(Decorator::Tab* tab, BRect invalid)
491+{
492+ STRACE(("_DrawTab(%.1f,%.1f,%.1f,%.1f)\n",
493+ invalid.left, invalid.top, invalid.right, invalid.bottom));
494+ const BRect& tabRect = tab->tabRect;
495+ // If a window has a tab, this will draw it and any buttons which are
496+ // in it.
497+ if (!tabRect.IsValid() || !invalid.Intersects(tabRect))
498+ return;
499+
500+ ComponentColors colors;
501+ _GetComponentColors(COMPONENT_TAB, colors, tab);
502+
503+ // outer frame
504+ fDrawingEngine->StrokeLine(tabRect.LeftTop(), tabRect.LeftBottom(),
505+ colors[COLOR_TAB_FRAME_LIGHT]);
506+ fDrawingEngine->StrokeLine(tabRect.LeftTop(), tabRect.RightTop(),
507+ colors[COLOR_TAB_FRAME_LIGHT]);
508+ if (tab->look != kLeftTitledWindowLook) {
509+ fDrawingEngine->StrokeLine(tabRect.RightTop(), tabRect.RightBottom(),
510+ colors[COLOR_TAB_FRAME_DARK]);
511+ } else {
512+ fDrawingEngine->StrokeLine(tabRect.LeftBottom(),
513+ tabRect.RightBottom(), colors[COLOR_TAB_FRAME_DARK]);
514+ }
515+
516+ float tabBotton = tabRect.bottom;
517+ if (fTopTab != tab)
518+ tabBotton -= 1;
519+
520+ // bevel
521+ fDrawingEngine->StrokeLine(BPoint(tabRect.left + 1, tabRect.top + 1),
522+ BPoint(tabRect.left + 1,
523+ tabBotton - (tab->look == kLeftTitledWindowLook ? 1 : 0)),
524+ colors[COLOR_TAB_BEVEL]);
525+ fDrawingEngine->StrokeLine(BPoint(tabRect.left + 1, tabRect.top + 1),
526+ BPoint(tabRect.right - (tab->look == kLeftTitledWindowLook ? 0 : 1),
527+ tabRect.top + 1),
528+ colors[COLOR_TAB_BEVEL]);
529+
530+ if (tab->look != kLeftTitledWindowLook) {
531+ fDrawingEngine->StrokeLine(BPoint(tabRect.right - 1, tabRect.top + 2),
532+ BPoint(tabRect.right - 1, tabBotton),
533+ colors[COLOR_TAB_SHADOW]);
534+ } else {
535+ fDrawingEngine->StrokeLine(
536+ BPoint(tabRect.left + 2, tabRect.bottom - 1),
537+ BPoint(tabRect.right, tabRect.bottom - 1),
538+ colors[COLOR_TAB_SHADOW]);
539+ }
540+
541+ // fill
542+ BGradientLinear gradient;
543+ gradient.SetStart(tabRect.LeftTop());
544+ gradient.AddColor(colors[COLOR_TAB_LIGHT], 0);
545+ gradient.AddColor(colors[COLOR_TAB], 255);
546+
547+ if (tab->look != kLeftTitledWindowLook) {
548+ gradient.SetEnd(tabRect.LeftBottom());
549+ fDrawingEngine->FillRect(BRect(tabRect.left + 2, tabRect.top + 2,
550+ tabRect.right - 2, tabBotton), gradient);
551+ } else {
552+ gradient.SetEnd(tabRect.RightTop());
553+ fDrawingEngine->FillRect(BRect(tabRect.left + 2, tabRect.top + 2,
554+ tabRect.right, tabRect.bottom - 2), gradient);
555+ }
556+
557+ _DrawTitle(tab, tabRect);
558+
559+ _DrawButtons(tab, invalid);
560+}
561+
562+
563+/*! \brief Actually draws the title
564+
565+ The main tasks for this function are to ensure that the decorator draws
566+ the title only in its own area and drawing the title itself.
567+ Using B_OP_COPY for drawing the title is recommended because of the marked
568+ performance hit of the other drawing modes, but it is not a requirement.
569+
570+ \param tab The \a tab to update.
571+ \param rect area of the title to update.
572+*/
573+void
574+DefaultDecorator::_DrawTitle(Decorator::Tab* _tab, BRect rect)
575+{
576+ STRACE(("_DrawTitle(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
577+ rect.bottom));
578+
579+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
580+
581+ const BRect& tabRect = tab->tabRect;
582+ const BRect& closeRect = tab->closeRect;
583+ const BRect& zoomRect = tab->zoomRect;
584+
585+ ComponentColors colors;
586+ _GetComponentColors(COMPONENT_TAB, colors, tab);
587+
588+ fDrawingEngine->SetDrawingMode(B_OP_OVER);
589+ fDrawingEngine->SetHighColor(colors[COLOR_TAB_TEXT]);
590+ fDrawingEngine->SetFont(fDrawState.Font());
591+
592+ // figure out position of text
593+ font_height fontHeight;
594+ fDrawState.Font().GetHeight(fontHeight);
595+
596+ BPoint titlePos;
597+ if (tab->look != kLeftTitledWindowLook) {
598+ titlePos.x = closeRect.IsValid() ? closeRect.right + tab->textOffset
599+ : tabRect.left + tab->textOffset;
600+ titlePos.y = floorf(((tabRect.top + 2.0) + tabRect.bottom
601+ + fontHeight.ascent + fontHeight.descent) / 2.0
602+ - fontHeight.descent + 0.5);
603+ } else {
604+ titlePos.x = floorf(((tabRect.left + 2.0) + tabRect.right
605+ + fontHeight.ascent + fontHeight.descent) / 2.0
606+ - fontHeight.descent + 0.5);
607+ titlePos.y = zoomRect.IsValid() ? zoomRect.top - tab->textOffset
608+ : tabRect.bottom - tab->textOffset;
609+ }
610+
611+ fDrawingEngine->DrawString(tab->truncatedTitle, tab->truncatedTitleLength,
612+ titlePos);
613+
614+ fDrawingEngine->SetDrawingMode(B_OP_COPY);
615+}
616+
617+
618+/*! \brief Actually draws the close button
619+
620+ Unless a subclass has a particularly large button, it is probably
621+ unnecessary to check the update rectangle.
622+
623+ \param _tab The \a tab to update.
624+ \param direct Draw without double buffering.
625+ \param rect The area of the button to update.
626+*/
627+void
628+DefaultDecorator::_DrawClose(Decorator::Tab* _tab, bool direct, BRect rect)
629+{
630+ STRACE(("_DrawClose(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
631+ rect.bottom));
632+
633+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
634+
635+ int32 index = (tab->buttonFocus ? 0 : 1) + (tab->closePressed ? 0 : 2);
636+ ServerBitmap* bitmap = tab->closeBitmaps[index];
637+ if (bitmap == NULL) {
638+ bitmap = _GetBitmapForButton(tab, COMPONENT_CLOSE_BUTTON,
639+ tab->closePressed, rect.IntegerWidth(), rect.IntegerHeight());
640+ tab->closeBitmaps[index] = bitmap;
641+ }
642+
643+ _DrawButtonBitmap(bitmap, direct, rect);
644+}
645+
646+
647+/*! \brief Actually draws the zoom button
648+
649+ Unless a subclass has a particularly large button, it is probably
650+ unnecessary to check the update rectangle.
651+
652+ \param _tab The \a tab to update.
653+ \param direct Draw without double buffering.
654+ \param rect The area of the button to update.
655+*/
656+void
657+DefaultDecorator::_DrawZoom(Decorator::Tab* _tab, bool direct, BRect rect)
658+{
659+ STRACE(("_DrawZoom(%f,%f,%f,%f)\n", rect.left, rect.top, rect.right,
660+ rect.bottom));
661+
662+ if (rect.IntegerWidth() < 1)
663+ return;
664+
665+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
666+ int32 index = (tab->buttonFocus ? 0 : 1) + (tab->zoomPressed ? 0 : 2);
667+ ServerBitmap* bitmap = tab->zoomBitmaps[index];
668+ if (bitmap == NULL) {
669+ bitmap = _GetBitmapForButton(tab, COMPONENT_ZOOM_BUTTON,
670+ tab->zoomPressed, rect.IntegerWidth(), rect.IntegerHeight());
671+ tab->zoomBitmaps[index] = bitmap;
672+ }
673+
674+ _DrawButtonBitmap(bitmap, direct, rect);
675+}
676+
677+
678+void
679+DefaultDecorator::_DrawMinimize(Decorator::Tab* tab, bool direct, BRect rect)
680+{
681+ // This decorator doesn't have this button
682+}
683+
684+
685+// #pragma mark - Private methods
686+
687+
688+void
689+DefaultDecorator::_DrawButtonBitmap(ServerBitmap* bitmap, bool direct,
690+ BRect rect)
691+{
692+ if (bitmap == NULL)
693+ return;
694+
695+ bool copyToFrontEnabled = fDrawingEngine->CopyToFrontEnabled();
696+ fDrawingEngine->SetCopyToFrontEnabled(direct);
697+ drawing_mode oldMode;
698+ fDrawingEngine->SetDrawingMode(B_OP_OVER, oldMode);
699+ fDrawingEngine->DrawBitmap(bitmap, rect.OffsetToCopy(0, 0), rect);
700+ fDrawingEngine->SetDrawingMode(oldMode);
701+ fDrawingEngine->SetCopyToFrontEnabled(copyToFrontEnabled);
702+}
703+
704+
705+/*! \brief Draws a framed rectangle with a gradient.
706+ \param engine The drawing engine to use.
707+ \param rect The rectangular area to draw in.
708+ \param down The rectangle should be drawn recessed or not.
709+ \param colors A button color array of the colors to be used.
710+*/
711+void
712+DefaultDecorator::_DrawBlendedRect(DrawingEngine* engine, const BRect rect,
713+ bool down, const ComponentColors& colors)
714+{
715+ // figure out which colors to use
716+ rgb_color startColor, endColor;
717+ if (down) {
718+ startColor = tint_color(colors[COLOR_BUTTON], B_DARKEN_1_TINT);
719+ endColor = colors[COLOR_BUTTON_LIGHT];
720+ } else {
721+ startColor = tint_color(colors[COLOR_BUTTON], B_LIGHTEN_MAX_TINT);
722+ endColor = colors[COLOR_BUTTON];
723+ }
724+
725+ // fill
726+ BRect fillRect(rect.InsetByCopy(1.0f, 1.0f));
727+
728+ BGradientLinear gradient;
729+ gradient.SetStart(fillRect.LeftTop());
730+ gradient.SetEnd(fillRect.RightBottom());
731+ gradient.AddColor(startColor, 0);
732+ gradient.AddColor(endColor, 255);
733+
734+ engine->FillRect(fillRect, gradient);
735+
736+ // outline
737+ engine->StrokeRect(rect, tint_color(colors[COLOR_BUTTON], B_DARKEN_2_TINT));
738+}
739+
740+
741+ServerBitmap*
742+DefaultDecorator::_GetBitmapForButton(Decorator::Tab* tab, Component item,
743+ bool down, int32 width, int32 height)
744+{
745+ // TODO: the list of shared bitmaps is never freed
746+ struct decorator_bitmap {
747+ Component item;
748+ bool down;
749+ int32 width;
750+ int32 height;
751+ rgb_color baseColor;
752+ rgb_color lightColor;
753+ UtilityBitmap* bitmap;
754+ decorator_bitmap* next;
755+ };
756+
757+ static BLocker sBitmapListLock("decorator lock", true);
758+ static decorator_bitmap* sBitmapList = NULL;
759+
760+ ComponentColors colors;
761+ _GetComponentColors(item, colors, tab);
762+
763+ BAutolock locker(sBitmapListLock);
764+
765+ // search our list for a matching bitmap
766+ // TODO: use a hash map instead?
767+ decorator_bitmap* current = sBitmapList;
768+ while (current) {
769+ if (current->item == item && current->down == down
770+ && current->width == width && current->height == height
771+ && current->baseColor == colors[COLOR_BUTTON]
772+ && current->lightColor == colors[COLOR_BUTTON_LIGHT]) {
773+ return current->bitmap;
774+ }
775+
776+ current = current->next;
777+ }
778+
779+ static BitmapDrawingEngine* sBitmapDrawingEngine = NULL;
780+
781+ // didn't find any bitmap, create a new one
782+ if (sBitmapDrawingEngine == NULL)
783+ sBitmapDrawingEngine = new(std::nothrow) BitmapDrawingEngine();
784+ if (sBitmapDrawingEngine == NULL
785+ || sBitmapDrawingEngine->SetSize(width, height) != B_OK)
786+ return NULL;
787+
788+ BRect rect(0, 0, width - 1, height - 1);
789+
790+ STRACE(("DefaultDecorator creating bitmap for %s %s at size %ldx%ld\n",
791+ item == COMPONENT_CLOSE_BUTTON ? "close" : "zoom",
792+ down ? "down" : "up", width, height));
793+ switch (item) {
794+ case COMPONENT_CLOSE_BUTTON:
795+ _DrawBlendedRect(sBitmapDrawingEngine, rect, down, colors);
796+ break;
797+
798+ case COMPONENT_ZOOM_BUTTON:
799+ {
800+ sBitmapDrawingEngine->FillRect(rect, B_TRANSPARENT_COLOR);
801+ // init the background
802+
803+ float inset = floorf(width / 4.0);
804+ BRect zoomRect(rect);
805+ zoomRect.left += inset;
806+ zoomRect.top += inset;
807+ _DrawBlendedRect(sBitmapDrawingEngine, zoomRect, down, colors);
808+
809+ inset = floorf(width / 2.1);
810+ zoomRect = rect;
811+ zoomRect.right -= inset;
812+ zoomRect.bottom -= inset;
813+ _DrawBlendedRect(sBitmapDrawingEngine, zoomRect, down, colors);
814+ break;
815+ }
816+
817+ default:
818+ break;
819+ }
820+
821+ UtilityBitmap* bitmap = sBitmapDrawingEngine->ExportToBitmap(width, height,
822+ B_RGB32);
823+ if (bitmap == NULL)
824+ return NULL;
825+
826+ // bitmap ready, put it into the list
827+ decorator_bitmap* entry = new(std::nothrow) decorator_bitmap;
828+ if (entry == NULL) {
829+ delete bitmap;
830+ return NULL;
831+ }
832+
833+ entry->item = item;
834+ entry->down = down;
835+ entry->width = width;
836+ entry->height = height;
837+ entry->bitmap = bitmap;
838+ entry->baseColor = colors[COLOR_BUTTON];
839+ entry->lightColor = colors[COLOR_BUTTON_LIGHT];
840+ entry->next = sBitmapList;
841+ sBitmapList = entry;
842+
843+ return bitmap;
844+}
845+
846+
847+void
848+DefaultDecorator::_GetComponentColors(Component component,
849+ ComponentColors _colors, Decorator::Tab* tab)
850+{
851+ // get the highlight for our component
852+ Region region = REGION_NONE;
853+ switch (component) {
854+ case COMPONENT_TAB:
855+ region = REGION_TAB;
856+ break;
857+ case COMPONENT_CLOSE_BUTTON:
858+ region = REGION_CLOSE_BUTTON;
859+ break;
860+ case COMPONENT_ZOOM_BUTTON:
861+ region = REGION_ZOOM_BUTTON;
862+ break;
863+ case COMPONENT_LEFT_BORDER:
864+ region = REGION_LEFT_BORDER;
865+ break;
866+ case COMPONENT_RIGHT_BORDER:
867+ region = REGION_RIGHT_BORDER;
868+ break;
869+ case COMPONENT_TOP_BORDER:
870+ region = REGION_TOP_BORDER;
871+ break;
872+ case COMPONENT_BOTTOM_BORDER:
873+ region = REGION_BOTTOM_BORDER;
874+ break;
875+ case COMPONENT_RESIZE_CORNER:
876+ region = REGION_RIGHT_BOTTOM_CORNER;
877+ break;
878+ }
879+
880+ return GetComponentColors(component, RegionHighlight(region), _colors, tab);
881+}
1@@ -0,0 +1,70 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * Ryan Leavengood, leavengood@gmail.com
10+ * Philippe Saint-Pierre, stpere@gmail.com
11+ * John Scipione, jscipione@gmail.com
12+ * Ingo Weinhold, ingo_weinhold@gmx.de
13+ * Clemens Zeidler, haiku@clemens-zeidler.de
14+ * Joseph Groover, looncraz@looncraz.net
15+ * Tri-Edge AI
16+ * Jacob Secunda, secundja@gmail.com
17+ */
18+#ifndef DEFAULT_DECORATOR_H
19+#define DEFAULT_DECORATOR_H
20+
21+
22+#include "TabDecorator.h"
23+
24+
25+class Desktop;
26+class ServerBitmap;
27+
28+
29+class DefaultDecorator: public TabDecorator {
30+public:
31+ DefaultDecorator(DesktopSettings& settings,
32+ BRect frame, Desktop* desktop);
33+ virtual ~DefaultDecorator();
34+
35+ virtual void GetComponentColors(Component component,
36+ uint8 highlight, ComponentColors _colors,
37+ Decorator::Tab* tab = NULL);
38+
39+ virtual void UpdateColors(DesktopSettings& settings);
40+
41+protected:
42+ virtual void _DrawFrame(BRect rect);
43+
44+ virtual void _DrawTab(Decorator::Tab* tab, BRect r);
45+ virtual void _DrawTitle(Decorator::Tab* tab, BRect r);
46+ virtual void _DrawClose(Decorator::Tab* tab, bool direct,
47+ BRect rect);
48+ virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
49+ BRect rect);
50+ virtual void _DrawMinimize(Decorator::Tab* tab, bool direct,
51+ BRect rect);
52+ virtual void _DrawResizeKnob(BRect r, bool full,
53+ const ComponentColors& color);
54+
55+private:
56+ void _DrawButtonBitmap(ServerBitmap* bitmap,
57+ bool direct, BRect rect);
58+ void _DrawBlendedRect(DrawingEngine *engine,
59+ const BRect rect, bool down,
60+ const ComponentColors& colors);
61+ ServerBitmap* _GetBitmapForButton(Decorator::Tab* tab,
62+ Component item, bool down, int32 width,
63+ int32 height);
64+
65+ void _GetComponentColors(Component component,
66+ ComponentColors _colors,
67+ Decorator::Tab* tab = NULL);
68+};
69+
70+
71+#endif // DEFAULT_DECORATOR_H
1@@ -0,0 +1,120 @@
2+/*
3+ * Copyright 2001-2010, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Adi Oanca <adioanca@gmail.com>
9+ * Stephan Aßmus <superstippi@gmx.de>
10+ * Axel Dörfler <axeld@pinc-software.de>
11+ * Brecht Machiels <brecht@mos6581.org>
12+ * Clemens Zeidler <haiku@clemens-zeidler.de>
13+ * Ingo Weinhold <ingo_weinhold@gmx.de>
14+ */
15+#ifndef DEFAULT_WINDOW_BEHAVIOUR_H
16+#define DEFAULT_WINDOW_BEHAVIOUR_H
17+
18+
19+#include "WindowBehaviour.h"
20+
21+#include "Decorator.h"
22+#include "MagneticBorder.h"
23+#include "ServerCursor.h"
24+
25+#include <AutoDeleter.h>
26+
27+
28+class Desktop;
29+class Window;
30+
31+
32+class DefaultWindowBehaviour : public WindowBehaviour {
33+public:
34+ DefaultWindowBehaviour(Window* window);
35+ virtual ~DefaultWindowBehaviour();
36+
37+ virtual bool MouseDown(BMessage* message, BPoint where,
38+ int32 lastHitRegion, int32& clickCount,
39+ int32& _hitRegion);
40+ virtual void MouseUp(BMessage* message, BPoint where);
41+ virtual void MouseMoved(BMessage *message, BPoint where,
42+ bool isFake);
43+
44+ virtual void ModifiersChanged(int32 modifiers);
45+
46+protected:
47+ virtual bool AlterDeltaForSnap(Window* window, BPoint& delta,
48+ bigtime_t now);
49+private:
50+ enum Action {
51+ ACTION_NONE,
52+ ACTION_ZOOM,
53+ ACTION_CLOSE,
54+ ACTION_MINIMIZE,
55+ ACTION_TAB,
56+ ACTION_DRAG,
57+ ACTION_SLIDE_TAB,
58+ ACTION_RESIZE,
59+ ACTION_RESIZE_BORDER
60+ };
61+
62+ enum {
63+ // 1 for the "natural" resize border, -1 for the opposite, so
64+ // multiplying the movement delta by that value results in the
65+ // size change.
66+ LEFT = -1,
67+ TOP = -1,
68+ NONE = 0,
69+ RIGHT = 1,
70+ BOTTOM = 1
71+ };
72+
73+ struct State;
74+ struct MouseTrackingState;
75+ struct DragState;
76+ struct ResizeState;
77+ struct SlideTabState;
78+ struct ResizeBorderState;
79+ struct DecoratorButtonState;
80+ struct ManageWindowState;
81+
82+ // to keep gcc 2 happy
83+ friend struct State;
84+ friend struct MouseTrackingState;
85+ friend struct DragState;
86+ friend struct ResizeState;
87+ friend struct SlideTabState;
88+ friend struct ResizeBorderState;
89+ friend struct DecoratorButtonState;
90+ friend struct ManageWindowState;
91+
92+private:
93+ bool _IsWindowModifier(int32 modifiers) const;
94+ Decorator::Region _RegionFor(const BMessage* message,
95+ int32& tab) const;
96+
97+ void _SetBorderHighlights(int8 horizontal,
98+ int8 vertical, bool active);
99+
100+ ServerCursor* _ResizeCursorFor(int8 horizontal,
101+ int8 vertical);
102+ void _SetResizeCursor(int8 horizontal,
103+ int8 vertical);
104+ void _ResetResizeCursor();
105+ static void _ComputeResizeDirection(float x, float y,
106+ int8& _horizontal, int8& _vertical);
107+
108+ void _NextState(State* state);
109+
110+protected:
111+ Window* fWindow;
112+ Desktop* fDesktop;
113+ ObjectDeleter<State>
114+ fState;
115+ int32 fLastModifiers;
116+
117+ MagneticBorder fMagneticBorder;
118+};
119+
120+
121+#endif // DEFAULT_WINDOW_BEHAVIOUR_H
+178,
-0
1@@ -0,0 +1,178 @@
2+/*
3+ * Copyright 2015, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Joseph Groover <looncraz@looncraz.net>
8+*/
9+#ifndef AS_DELAYED_MESSAGE_H
10+#define AS_DELAYED_MESSAGE_H
11+
12+
13+#include <ObjectList.h>
14+#include <OS.h>
15+
16+
17+//! Method by which to merge DelayedMessages with the same code.
18+enum DMMergeMode {
19+ DM_NO_MERGE = 0, // Will send this message, and the other(s)
20+ DM_MERGE_REPLACE = 1, // Replace older data with newer data
21+ DM_MERGE_CANCEL = 2, // keeps older data, cancels this message
22+ DM_MERGE_DUPLICATES = 3 // If data is the same, cancel new message
23+};
24+
25+
26+//! Merge-mode data-matching, set which data must match to merge messages.
27+enum {
28+ DM_DATA_DEFAULT = 0, // Match all for DUPLICATES & none for REPLACE modes.
29+ DM_DATA_1 = 1 << 0,
30+ DM_DATA_2 = 1 << 1,
31+ DM_DATA_3 = 1 << 2,
32+ DM_DATA_4 = 1 << 3,
33+ DM_DATA_5 = 1 << 4,
34+ DM_DATA_6 = 1 << 5
35+};
36+
37+
38+//! Convenient delay definitions.
39+enum {
40+ DM_MINIMUM_DELAY = 500ULL,
41+ DM_SHORT_DELAY = 1000ULL,
42+ DM_120HZ_DELAY = 8888ULL,
43+ DM_60HZ_DELAY = 16666ULL,
44+ DM_MEDIUM_DELAY = 15000ULL,
45+ DM_30HZ_DELAY = 33332ULL,
46+ DM_15HZ_DELAY = 66664ULL,
47+ DM_LONG_DELAY = 100000ULL,
48+ DM_QUARTER_SECOND_DELAY = 250000ULL,
49+ DM_HALF_SECOND_DELAY = 500000ULL,
50+ DM_ONE_SECOND_DELAY = 1000000ULL,
51+ DM_ONE_MINUTE_DELAY = DM_ONE_SECOND_DELAY * 60,
52+ DM_ONE_HOUR_DELAY = DM_ONE_MINUTE_DELAY * 60
53+};
54+
55+
56+class DelayedMessageData;
57+
58+
59+/*! \class DelayedMessage
60+ \brief Friendly API for creating messages to be sent at a future time.
61+
62+ Messages can be sent with a relative delay, or at a set time. Messages with
63+ the same code can be merged according to various rules. Each message can
64+ have any number of target recipients.
65+
66+ DelayedMessage is a throw-away object, it is to be created on the stack,
67+ Flush()'d, then left to be destructed when out of scope.
68+*/
69+class DelayedMessage {
70+ typedef void(*FailureCallback)(int32 code, port_id port, void* data);
71+public:
72+ DelayedMessage(int32 code, bigtime_t delay,
73+ bool isSpecificTime = false);
74+
75+ ~DelayedMessage();
76+
77+ // At least one target port is required.
78+ bool AddTarget(port_id port);
79+
80+ // Merge messages with the same code according to the following
81+ // rules and data matching mask.
82+ void SetMerge(DMMergeMode mode, uint32 match = 0);
83+
84+ // Called for each port on which the message was failed to be sent.
85+ void SetFailureCallback(FailureCallback callback,
86+ void* data = NULL);
87+
88+ template <class Type>
89+ status_t Attach(const Type& data);
90+ status_t Attach(const void* data, size_t size);
91+
92+ template <class Type>
93+ status_t AttachList(const BObjectList<Type>& list);
94+
95+ template <class Type>
96+ status_t AttachList(const BObjectList<Type>& list,
97+ bool* whichArray);
98+
99+ status_t Flush();
100+
101+ // Private
102+ DelayedMessageData* HandOff();
103+ DelayedMessageData* Data() {return fData;}
104+
105+private:
106+ // Forbidden methods - these are one time-use objects.
107+ void* operator new(size_t);
108+ void* operator new[](size_t);
109+
110+ DelayedMessageData* fData;
111+ bool fHandedOff;
112+};
113+
114+
115+// #pragma mark Implementation
116+
117+
118+template <class Type>
119+status_t
120+DelayedMessage::Attach(const Type& data)
121+{
122+ return Attach(&data, sizeof(Type));
123+}
124+
125+
126+template <class Type>
127+status_t
128+DelayedMessage::AttachList(const BObjectList<Type>& list)
129+{
130+ if (list.CountItems() == 0)
131+ return B_BAD_VALUE;
132+
133+ status_t error = Attach<int32>(list.CountItems());
134+
135+ for (int32 index = 0; index < list.CountItems(); ++index) {
136+ if (error != B_OK)
137+ break;
138+
139+ error = Attach<Type>(*(list.ItemAt(index)));
140+ }
141+
142+ return error;
143+}
144+
145+
146+template <class Type>
147+status_t
148+DelayedMessage::AttachList(const BObjectList<Type>& list, bool* which)
149+{
150+ if (list.CountItems() == 0)
151+ return B_BAD_VALUE;
152+
153+ if (which == NULL)
154+ return AttachList(list);
155+
156+ int32 count = 0;
157+ for (int32 index = 0; index < list.CountItems(); ++index) {
158+ if (which[index])
159+ ++count;
160+ }
161+
162+ if (count == 0)
163+ return B_BAD_VALUE;
164+
165+ status_t error = Attach<int32>(count);
166+
167+ for (int32 index = 0; index < list.CountItems(); ++index) {
168+ if (error != B_OK)
169+ break;
170+
171+ if (which[index])
172+ error = Attach<Type>(*list.ItemAt(index));
173+ }
174+
175+ return error;
176+}
177+
178+
179+#endif // AS_DELAYED_MESSAGE_H
+388,
-0
1@@ -0,0 +1,388 @@
2+/*
3+ * Copyright 2001-2020, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Adrian Oanca, adioanca@cotty.iren.ro
8+ * Stephan Aßmus, superstippi@gmx.de
9+ * Axel Dörfler, axeld@pinc-software.de
10+ * Andrej Spielmann, andrej.spielmann@seh.ox.ac.uk
11+ * Brecht Machiels, brecht@mos6581.org
12+ * Clemens Zeidler, haiku@clemens-zeidler.de
13+ * Joseph Groover, looncraz@looncraz.net
14+ * Tri-Edge AI
15+ * Jacob Secunda, secundja@gmail.com
16+ */
17+#ifndef DESKTOP_H
18+#define DESKTOP_H
19+
20+
21+#include <AutoDeleter.h>
22+#include <Autolock.h>
23+#include <InterfaceDefs.h>
24+#include <List.h>
25+#include <Menu.h>
26+#include <ObjectList.h>
27+#include <Region.h>
28+#include <String.h>
29+#include <Window.h>
30+
31+#include <ServerProtocolStructs.h>
32+
33+#include "CursorManager.h"
34+#include "DelayedMessage.h"
35+#include "DesktopListener.h"
36+#include "DesktopSettings.h"
37+#include "EventDispatcher.h"
38+#include "MessageLooper.h"
39+#include "MultiLocker.h"
40+#include "Screen.h"
41+#include "ScreenManager.h"
42+#include "ServerCursor.h"
43+#include "StackAndTile.h"
44+#include "VirtualScreen.h"
45+#include "WindowList.h"
46+#include "Workspace.h"
47+#include "WorkspacePrivate.h"
48+
49+
50+class BMessage;
51+
52+class DecorAddOn;
53+class DrawingEngine;
54+class HWInterface;
55+class ServerApp;
56+class Window;
57+class WorkspacesView;
58+struct server_read_only_memory;
59+
60+namespace BPrivate {
61+ class LinkSender;
62+};
63+
64+
65+class Desktop : public DesktopObservable, public MessageLooper,
66+ public ScreenOwner {
67+public:
68+ Desktop(uid_t userID,
69+ const char* targetScreen);
70+ virtual ~Desktop();
71+
72+ void RegisterListener(DesktopListener* listener);
73+
74+ status_t Init();
75+
76+ uid_t UserID() const { return fUserID; }
77+ const char* TargetScreen() { return fTargetScreen; }
78+ virtual port_id MessagePort() const { return fMessagePort; }
79+ area_id SharedReadOnlyArea() const
80+ { return fSharedReadOnlyArea; }
81+
82+ ::EventDispatcher& EventDispatcher() { return fEventDispatcher; }
83+
84+ void BroadcastToAllApps(int32 code);
85+ void BroadcastToAllWindows(int32 code);
86+
87+ int32 GetAllWindowTargets(DelayedMessage& message);
88+ int32 GetAllAppTargets(DelayedMessage& message);
89+
90+ filter_result KeyEvent(uint32 what, int32 key,
91+ int32 modifiers);
92+ // Locking
93+ bool LockSingleWindow()
94+ { return fWindowLock.ReadLock(); }
95+ void UnlockSingleWindow()
96+ { fWindowLock.ReadUnlock(); }
97+
98+ bool LockAllWindows()
99+ { return fWindowLock.WriteLock(); }
100+ void UnlockAllWindows()
101+ { fWindowLock.WriteUnlock(); }
102+
103+ const MultiLocker& WindowLocker() { return fWindowLock; }
104+
105+ // Mouse and cursor methods
106+
107+ void SetCursor(ServerCursor* cursor);
108+ ServerCursorReference Cursor() const;
109+ void SetManagementCursor(ServerCursor* newCursor);
110+
111+ void SetLastMouseState(const BPoint& position,
112+ int32 buttons, Window* windowUnderMouse);
113+ // for use by the mouse filter only
114+ // both mouse position calls require
115+ // the Desktop object to be locked
116+ // already
117+ void GetLastMouseState(BPoint* position,
118+ int32* buttons) const;
119+ // for use by ServerWindow
120+
121+ CursorManager& GetCursorManager() { return fCursorManager; }
122+
123+ // Screen and drawing related methods
124+
125+ status_t SetScreenMode(int32 workspace, int32 id,
126+ const display_mode& mode, bool makeDefault);
127+ status_t GetScreenMode(int32 workspace, int32 id,
128+ display_mode& mode);
129+ status_t GetScreenFrame(int32 workspace, int32 id,
130+ BRect& frame);
131+ void RevertScreenModes(uint32 workspaces);
132+
133+ status_t SetBrightness(int32 id, float brightness);
134+
135+ MultiLocker& ScreenLocker() { return fScreenLock; }
136+
137+ status_t LockDirectScreen(team_id team);
138+ status_t UnlockDirectScreen(team_id team);
139+
140+ const ::VirtualScreen& VirtualScreen() const
141+ { return fVirtualScreen; }
142+ DrawingEngine* GetDrawingEngine() const
143+ { return fVirtualScreen.DrawingEngine(); }
144+ ::HWInterface* HWInterface() const
145+ { return fVirtualScreen.HWInterface(); }
146+
147+ void RebuildAndRedrawAfterWindowChange(
148+ Window* window, BRegion& dirty);
149+ // the window lock must be held when calling
150+ // this function
151+
152+ // ScreenOwner implementation
153+ virtual void ScreenRemoved(Screen* screen) {}
154+ virtual void ScreenAdded(Screen* screen) {}
155+ virtual void ScreenChanged(Screen* screen);
156+ virtual bool ReleaseScreen(Screen* screen) { return false; }
157+
158+ // Workspace methods
159+
160+ void SetWorkspaceAsync(int32 index,
161+ bool moveFocusWindow = false);
162+ void SetWorkspace(int32 index,
163+ bool moveFocusWindow = false);
164+ int32 CurrentWorkspace()
165+ { return fCurrentWorkspace; }
166+ Workspace::Private& WorkspaceAt(int32 index)
167+ { return fWorkspaces[index]; }
168+ status_t SetWorkspacesLayout(int32 columns, int32 rows);
169+ BRect WorkspaceFrame(int32 index) const;
170+
171+ void StoreWorkspaceConfiguration(int32 index);
172+
173+ void AddWorkspacesView(WorkspacesView* view);
174+ void RemoveWorkspacesView(WorkspacesView* view);
175+
176+ // Window methods
177+
178+ void SelectWindow(Window* window);
179+ void ActivateWindow(Window* window);
180+ void SendWindowBehind(Window* window,
181+ Window* behindOf = NULL,
182+ bool sendStack = true);
183+
184+ void ShowWindow(Window* window);
185+ void HideWindow(Window* window,
186+ bool fromMinimize = false);
187+ void MinimizeWindow(Window* window, bool minimize);
188+
189+ void MoveWindowBy(Window* window, float x, float y,
190+ int32 workspace = -1);
191+ void ResizeWindowBy(Window* window, float x,
192+ float y);
193+ void SetWindowOutlinesDelta(Window* window,
194+ BPoint delta);
195+ bool SetWindowTabLocation(Window* window,
196+ float location, bool isShifting);
197+ bool SetWindowDecoratorSettings(Window* window,
198+ const BMessage& settings);
199+
200+ void SetWindowWorkspaces(Window* window,
201+ uint32 workspaces);
202+
203+ void AddWindow(Window* window);
204+ void RemoveWindow(Window* window);
205+
206+ bool AddWindowToSubset(Window* subset,
207+ Window* window);
208+ void RemoveWindowFromSubset(Window* subset,
209+ Window* window);
210+
211+ void FontsChanged(Window* window);
212+ void ColorUpdated(Window* window, color_which which,
213+ rgb_color color);
214+
215+ void SetWindowLook(Window* window, window_look look);
216+ void SetWindowFeel(Window* window, window_feel feel);
217+ void SetWindowFlags(Window* window, uint32 flags);
218+ void SetWindowTitle(Window* window,
219+ const char* title);
220+
221+ Window* FocusWindow() const { return fFocus; }
222+ Window* FrontWindow() const { return fFront; }
223+ Window* BackWindow() const { return fBack; }
224+
225+ Window* WindowAt(BPoint where);
226+
227+ Window* MouseEventWindow() const
228+ { return fMouseEventWindow; }
229+ void SetMouseEventWindow(Window* window);
230+
231+ void SetViewUnderMouse(const Window* window,
232+ int32 viewToken);
233+ int32 ViewUnderMouse(const Window* window);
234+
235+ EventTarget* KeyboardEventTarget();
236+
237+ void SetFocusWindow(Window* window = NULL);
238+ void SetFocusLocked(const Window* window);
239+
240+ Window* FindWindowByClientToken(int32 token,
241+ team_id teamID);
242+ EventTarget* FindTarget(BMessenger& messenger);
243+
244+ void MarkDirty(BRegion& region);
245+ void Redraw();
246+ void RedrawBackground();
247+
248+ bool ReloadDecor(DecorAddOn* oldDecor);
249+
250+ BRegion& BackgroundRegion()
251+ { return fBackgroundRegion; }
252+
253+ void MinimizeApplication(team_id team);
254+ void BringApplicationToFront(team_id team);
255+ void WindowAction(int32 windowToken, int32 action);
256+
257+ void WriteWindowList(team_id team,
258+ BPrivate::LinkSender& sender);
259+ void WriteWindowInfo(int32 serverToken,
260+ BPrivate::LinkSender& sender);
261+ void WriteApplicationOrder(int32 workspace,
262+ BPrivate::LinkSender& sender);
263+ void WriteWindowOrder(int32 workspace,
264+ BPrivate::LinkSender& sender);
265+
266+ //! The window lock must be held when accessing a window list!
267+ WindowList& CurrentWindows();
268+ WindowList& AllWindows();
269+
270+ Window* WindowForClientLooperPort(port_id port);
271+
272+ StackAndTile* GetStackAndTile() { return &fStackAndTile; }
273+private:
274+ WindowList& _Windows(int32 index);
275+
276+ void _FlushPendingColors();
277+
278+ void _LaunchInputServer();
279+ void _GetLooperName(char* name, size_t size);
280+ void _PrepareQuit();
281+ void _DispatchMessage(int32 code,
282+ BPrivate::LinkReceiver &link);
283+
284+ void _UpdateFloating(int32 previousWorkspace = -1,
285+ int32 nextWorkspace = -1,
286+ Window* mouseEventWindow = NULL);
287+ void _UpdateBack();
288+ void _UpdateFront(bool updateFloating = true);
289+ void _UpdateFronts(bool updateFloating = true);
290+ bool _WindowHasModal(Window* window) const;
291+ bool _WindowCanHaveFocus(Window* window) const;
292+
293+ void _WindowChanged(Window* window);
294+ void _WindowRemoved(Window* window);
295+
296+ void _ShowWindow(Window* window,
297+ bool affectsOtherWindows = true);
298+ void _HideWindow(Window* window);
299+
300+ void _UpdateSubsetWorkspaces(Window* window,
301+ int32 previousIndex = -1,
302+ int32 newIndex = -1);
303+ void _ChangeWindowWorkspaces(Window* window,
304+ uint32 oldWorkspaces, uint32 newWorkspaces);
305+ void _BringWindowsToFront(WindowList& windows,
306+ int32 list, bool wereVisible);
307+ Window* _LastFocusSubsetWindow(Window* window);
308+ bool _CheckSendFakeMouseMoved(
309+ const Window* lastWindowUnderMouse);
310+ void _SendFakeMouseMoved(Window* window = NULL);
311+
312+ Screen* _DetermineScreenFor(BRect frame);
313+ void _RebuildClippingForAllWindows(
314+ BRegion& stillAvailableOnScreen);
315+ void _TriggerWindowRedrawing(
316+ BRegion& newDirtyRegion);
317+ void _SetBackground(BRegion& background);
318+
319+ status_t _ActivateApp(team_id team);
320+
321+ void _SuspendDirectFrameBufferAccess();
322+ void _ResumeDirectFrameBufferAccess();
323+
324+ void _ScreenChanged(Screen* screen);
325+ void _SetCurrentWorkspaceConfiguration();
326+ void _SetWorkspace(int32 index,
327+ bool moveFocusWindow = false);
328+
329+private:
330+ friend class DesktopSettings;
331+ friend class LockedDesktopSettings;
332+
333+ uid_t fUserID;
334+ char* fTargetScreen;
335+ ::VirtualScreen fVirtualScreen;
336+ ObjectDeleter<DesktopSettingsPrivate>
337+ fSettings;
338+ port_id fMessagePort;
339+ ::EventDispatcher fEventDispatcher;
340+ area_id fSharedReadOnlyArea;
341+ server_read_only_memory* fServerReadOnlyMemory;
342+
343+ BLocker fApplicationsLock;
344+ BObjectList<ServerApp> fApplications;
345+
346+ sem_id fShutdownSemaphore;
347+ int32 fShutdownCount;
348+
349+ ::Workspace::Private fWorkspaces[kMaxWorkspaces];
350+ MultiLocker fScreenLock;
351+ BLocker fDirectScreenLock;
352+ team_id fDirectScreenTeam;
353+ int32 fCurrentWorkspace;
354+ int32 fPreviousWorkspace;
355+
356+ WindowList fAllWindows;
357+ WindowList fSubsetWindows;
358+ WindowList fFocusList;
359+ Window* fLastWorkspaceFocus[kMaxWorkspaces];
360+
361+ BObjectList<WorkspacesView> fWorkspacesViews;
362+ BLocker fWorkspacesLock;
363+
364+ CursorManager fCursorManager;
365+ ServerCursorReference fCursor;
366+ ServerCursorReference fManagementCursor;
367+
368+ MultiLocker fWindowLock;
369+
370+ BRegion fBackgroundRegion;
371+ BRegion fScreenRegion;
372+
373+ Window* fMouseEventWindow;
374+ const Window* fWindowUnderMouse;
375+ const Window* fLockedFocusWindow;
376+ int32 fViewUnderMouse;
377+ BPoint fLastMousePosition;
378+ int32 fLastMouseButtons;
379+
380+ Window* fFocus;
381+ Window* fFront;
382+ Window* fBack;
383+
384+ StackAndTile fStackAndTile;
385+
386+ BMessage fPendingColors;
387+};
388+
389+#endif // DESKTOP_H
1@@ -0,0 +1,151 @@
2+/*
3+ * Copyright 2010, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Clemens Zeidler <haiku@clemens-zeidler.de>
8+ */
9+#ifndef DESKTOP_LISTENER_H
10+#define DESKTOP_LISTENER_H
11+
12+
13+#include <util/DoublyLinkedList.h>
14+
15+#include <Point.h>
16+
17+#include <ServerLink.h>
18+#include "Window.h"
19+
20+
21+class BMessage;
22+class Desktop;
23+class Window;
24+
25+
26+class DesktopListener : public DoublyLinkedListLinkImpl<DesktopListener> {
27+public:
28+ virtual ~DesktopListener();
29+
30+ virtual int32 Identifier() = 0;
31+
32+ virtual void ListenerRegistered(Desktop* desktop) = 0;
33+ virtual void ListenerUnregistered() = 0;
34+
35+ virtual bool HandleMessage(Window* sender,
36+ BPrivate::LinkReceiver& link,
37+ BPrivate::LinkSender& reply) = 0;
38+
39+ virtual void WindowAdded(Window* window) = 0;
40+ virtual void WindowRemoved(Window* window) = 0;
41+
42+ virtual bool KeyPressed(uint32 what, int32 key,
43+ int32 modifiers) = 0;
44+ virtual void MouseEvent(BMessage* message) = 0;
45+ virtual void MouseDown(Window* window, BMessage* message,
46+ const BPoint& where) = 0;
47+ virtual void MouseUp(Window* window, BMessage* message,
48+ const BPoint& where) = 0;
49+ virtual void MouseMoved(Window* window, BMessage* message,
50+ const BPoint& where) = 0;
51+
52+ virtual void WindowMoved(Window* window) = 0;
53+ virtual void WindowResized(Window* window) = 0;
54+ virtual void WindowActivated(Window* window) = 0;
55+ virtual void WindowSentBehind(Window* window,
56+ Window* behindOf) = 0;
57+ virtual void WindowWorkspacesChanged(Window* window,
58+ uint32 workspaces) = 0;
59+ virtual void WindowHidden(Window* window,
60+ bool fromMinimize) = 0;
61+ virtual void WindowMinimized(Window* window,
62+ bool minimize) = 0;
63+
64+ virtual void WindowTabLocationChanged(Window* window,
65+ float location, bool isShifting) = 0;
66+ virtual void SizeLimitsChanged(Window* window,
67+ int32 minWidth, int32 maxWidth,
68+ int32 minHeight, int32 maxHeight) = 0;
69+ virtual void WindowLookChanged(Window* window,
70+ window_look look) = 0;
71+ virtual void WindowFeelChanged(Window* window,
72+ window_feel feel) = 0;
73+
74+ virtual bool SetDecoratorSettings(Window* window,
75+ const BMessage& settings) = 0;
76+ virtual void GetDecoratorSettings(Window* window,
77+ BMessage& settings) = 0;
78+};
79+
80+
81+typedef DoublyLinkedList<DesktopListener> DesktopListenerDLList;
82+
83+
84+class DesktopObservable {
85+public:
86+ DesktopObservable();
87+
88+ void RegisterListener(DesktopListener* listener,
89+ Desktop* desktop);
90+ void UnregisterListener(DesktopListener* listener);
91+ const DesktopListenerDLList& GetDesktopListenerList();
92+
93+ bool MessageForListener(Window* sender,
94+ BPrivate::LinkReceiver& link,
95+ BPrivate::LinkSender& reply);
96+
97+ void NotifyWindowAdded(Window* window);
98+ void NotifyWindowRemoved(Window* window);
99+
100+ bool NotifyKeyPressed(uint32 what, int32 key,
101+ int32 modifiers);
102+ void NotifyMouseEvent(BMessage* message);
103+ void NotifyMouseDown(Window* window,
104+ BMessage* message, const BPoint& where);
105+ void NotifyMouseUp(Window* window, BMessage* message,
106+ const BPoint& where);
107+ void NotifyMouseMoved(Window* window,
108+ BMessage* message, const BPoint& where);
109+
110+ void NotifyWindowMoved(Window* window);
111+ void NotifyWindowResized(Window* window);
112+ void NotifyWindowActivated(Window* window);
113+ void NotifyWindowSentBehind(Window* window,
114+ Window* behindOf);
115+ void NotifyWindowWorkspacesChanged(Window* window,
116+ uint32 workspaces);
117+ void NotifyWindowHidden(Window* window,
118+ bool fromMinimize);
119+ void NotifyWindowMinimized(Window* window,
120+ bool minimize);
121+
122+ void NotifyWindowTabLocationChanged(Window* window,
123+ float location, bool isShifting);
124+ void NotifySizeLimitsChanged(Window* window,
125+ int32 minWidth, int32 maxWidth,
126+ int32 minHeight, int32 maxHeight);
127+ void NotifyWindowLookChanged(Window* window,
128+ window_look look);
129+ void NotifyWindowFeelChanged(Window* window,
130+ window_feel feel);
131+
132+ bool SetDecoratorSettings(Window* window,
133+ const BMessage& settings);
134+ void GetDecoratorSettings(Window* window,
135+ BMessage& settings);
136+
137+private:
138+ class InvokeGuard {
139+ public:
140+ InvokeGuard(bool& invoking);
141+ ~InvokeGuard();
142+ private:
143+ bool& fInvoking;
144+ };
145+
146+ DesktopListenerDLList fDesktopListenerList;
147+
148+ // prevent recursive invokes
149+ bool fWeAreInvoking;
150+};
151+
152+#endif
1@@ -0,0 +1,121 @@
2+/*
3+ * Copyright 2001-2015, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
9+ * Joseph Groover <looncraz@looncraz.net>
10+ */
11+#ifndef DESKTOP_SETTINGS_H
12+#define DESKTOP_SETTINGS_H
13+
14+
15+#include <InterfaceDefs.h>
16+#include <Menu.h>
17+#include <Message.h>
18+
19+#include <ServerProtocolStructs.h>
20+
21+
22+class Desktop;
23+class DesktopSettingsPrivate;
24+class ServerFont;
25+
26+
27+static const int32 kMaxWorkspaces = 32;
28+
29+enum {
30+ kAllSettings = 0xff,
31+ kWorkspacesSettings = 0x01,
32+ kFontSettings = 0x02,
33+ kAppearanceSettings = 0x04,
34+ kMouseSettings = 0x08,
35+ kDraggerSettings = 0x10,
36+};
37+
38+
39+class DesktopSettings {
40+public:
41+ DesktopSettings(Desktop* desktop);
42+
43+ status_t Save(uint32 mask = kAllSettings);
44+
45+ void GetDefaultPlainFont(ServerFont& font) const;
46+ void GetDefaultBoldFont(ServerFont& font) const;
47+ void GetDefaultFixedFont(ServerFont& font) const;
48+
49+ void GetScrollBarInfo(scroll_bar_info& info) const;
50+ void GetMenuInfo(menu_info& info) const;
51+
52+ mode_mouse MouseMode() const;
53+ mode_focus_follows_mouse FocusFollowsMouseMode() const;
54+
55+ bool NormalMouse() const
56+ { return MouseMode() == B_NORMAL_MOUSE; }
57+ bool FocusFollowsMouse() const
58+ { return MouseMode()
59+ == B_FOCUS_FOLLOWS_MOUSE; }
60+ bool ClickToFocusMouse() const
61+ { return MouseMode()
62+ == B_CLICK_TO_FOCUS_MOUSE; }
63+
64+ bool AcceptFirstClick() const;
65+
66+ bool ShowAllDraggers() const;
67+
68+ int32 WorkspacesCount() const;
69+ int32 WorkspacesColumns() const;
70+ int32 WorkspacesRows() const;
71+ const BMessage* WorkspacesMessage(int32 index) const;
72+
73+ rgb_color UIColor(color_which which) const;
74+
75+ bool SubpixelAntialiasing() const;
76+ uint8 Hinting() const;
77+ uint8 SubpixelAverageWeight() const;
78+ bool IsSubpixelOrderingRegular() const;
79+
80+ const BString& ControlLook() const;
81+
82+protected:
83+ DesktopSettingsPrivate* fSettings;
84+};
85+
86+
87+class LockedDesktopSettings : public DesktopSettings {
88+public:
89+ LockedDesktopSettings(Desktop* desktop);
90+ ~LockedDesktopSettings();
91+
92+ void SetDefaultPlainFont(const ServerFont& font);
93+ void SetDefaultBoldFont(const ServerFont& font);
94+ void SetDefaultFixedFont(const ServerFont& font);
95+
96+ void SetScrollBarInfo(const scroll_bar_info& info);
97+ void SetMenuInfo(const menu_info& info);
98+
99+ void SetMouseMode(mode_mouse mode);
100+ void SetFocusFollowsMouseMode(
101+ mode_focus_follows_mouse mode);
102+ void SetAcceptFirstClick(bool acceptFirstClick);
103+
104+ void SetShowAllDraggers(bool show);
105+
106+ void SetUIColors(const BMessage& colors,
107+ bool* changed = NULL);
108+
109+ void SetSubpixelAntialiasing(bool subpix);
110+ void SetHinting(uint8 hinting);
111+ void SetSubpixelAverageWeight(uint8 averageWeight);
112+ void SetSubpixelOrderingRegular(
113+ bool subpixelOrdering);
114+
115+ status_t SetControlLook(const char* path);
116+
117+private:
118+ Desktop* fDesktop;
119+};
120+
121+
122+#endif /* DESKTOP_SETTINGS_H */
+230,
-0
1@@ -0,0 +1,230 @@
2+/*
3+ * Copyright 2001-2018, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Adi Oanca <adioanca@mymail.ro>
9+ * Stephan Aßmus <superstippi@gmx.de>
10+ * Axel Dörfler, axeld@pinc-software.de
11+ * Julian Harnath <julian.harnath@rwth-aachen.de>
12+ * Joseph Groover <looncraz@looncraz.net>
13+ */
14+#ifndef _DRAW_STATE_H_
15+#define _DRAW_STATE_H_
16+
17+
18+#include <AutoDeleter.h>
19+#include <AffineTransform.h>
20+#include <GraphicsDefs.h>
21+#include <InterfaceDefs.h>
22+#include <Point.h>
23+#include <Referenceable.h>
24+#include <View.h>
25+
26+#include "ServerFont.h"
27+#include "PatternHandler.h"
28+#include "SimpleTransform.h"
29+
30+class AlphaMask;
31+class BRegion;
32+class shape_data;
33+
34+namespace BPrivate {
35+ class LinkReceiver;
36+ class LinkSender;
37+};
38+
39+
40+class DrawState {
41+public:
42+ DrawState();
43+ DrawState(const DrawState& other);
44+public:
45+ virtual ~DrawState();
46+
47+ DrawState* PushState();
48+ DrawState* PopState();
49+ DrawState* PreviousState() const
50+ { return fPreviousState.Get(); }
51+
52+ uint16 ReadFontFromLink(BPrivate::LinkReceiver& link);
53+ // NOTE: ReadFromLink() does not read Font state!!
54+ // It was separate in ServerWindow, and I didn't
55+ // want to change it without knowing implications.
56+ void ReadFromLink(BPrivate::LinkReceiver& link);
57+ void WriteToLink(BPrivate::LinkSender& link) const;
58+
59+ // coordinate transformation
60+ void SetOrigin(BPoint origin);
61+ BPoint Origin() const
62+ { return fOrigin; }
63+ BPoint CombinedOrigin() const
64+ { return fCombinedOrigin; }
65+
66+ void SetScale(float scale);
67+ float Scale() const
68+ { return fScale; }
69+ float CombinedScale() const
70+ { return fCombinedScale; }
71+
72+ void SetTransform(BAffineTransform transform);
73+ BAffineTransform Transform() const
74+ { return fTransform; }
75+ BAffineTransform CombinedTransform() const
76+ { return fCombinedTransform; }
77+ void SetTransformEnabled(bool enabled);
78+
79+ DrawState* Squash() const;
80+
81+ // additional clipping as requested by client
82+ void SetClippingRegion(const BRegion* region);
83+
84+ bool HasClipping() const;
85+ bool HasAdditionalClipping() const;
86+ bool GetCombinedClippingRegion(BRegion* region) const;
87+
88+ bool ClipToRect(BRect rect, bool inverse);
89+ void ClipToShape(shape_data* shape, bool inverse);
90+
91+ void SetAlphaMask(AlphaMask* mask);
92+ AlphaMask* GetAlphaMask() const;
93+
94+ // coordinate transformations
95+ void Transform(SimpleTransform& transform) const;
96+ void InverseTransform(SimpleTransform& transform) const;
97+
98+ // color
99+ void SetHighColor(rgb_color color);
100+ rgb_color HighColor() const
101+ { return fHighColor; }
102+
103+ void SetLowColor(rgb_color color);
104+ rgb_color LowColor() const
105+ { return fLowColor; }
106+
107+ void SetHighUIColor(color_which which, float tint);
108+ color_which HighUIColor(float* tint) const;
109+
110+ void SetLowUIColor(color_which which, float tint);
111+ color_which LowUIColor(float* tint) const;
112+
113+ void SetPattern(const Pattern& pattern);
114+ const Pattern& GetPattern() const
115+ { return fPattern; }
116+
117+ // drawing/blending mode
118+ bool SetDrawingMode(drawing_mode mode);
119+ drawing_mode GetDrawingMode() const
120+ { return fDrawingMode; }
121+
122+ bool SetBlendingMode(source_alpha srcMode,
123+ alpha_function fncMode);
124+ source_alpha AlphaSrcMode() const
125+ { return fAlphaSrcMode; }
126+ alpha_function AlphaFncMode() const
127+ { return fAlphaFncMode; }
128+
129+ void SetDrawingModeLocked(bool locked);
130+
131+ // pen
132+ void SetPenLocation(BPoint location);
133+ BPoint PenLocation() const;
134+
135+ void SetPenSize(float size);
136+ float PenSize() const;
137+ float UnscaledPenSize() const;
138+
139+ // font
140+ void SetFont(const ServerFont& font,
141+ uint32 flags = B_FONT_ALL);
142+ const ServerFont& Font() const
143+ { return fFont; }
144+
145+ // overrides aliasing flag contained in SeverFont::Flags())
146+ void SetForceFontAliasing(bool aliasing);
147+ bool ForceFontAliasing() const
148+ { return fFontAliasing; }
149+
150+ // postscript style settings
151+ void SetLineCapMode(cap_mode mode);
152+ cap_mode LineCapMode() const
153+ { return fLineCapMode; }
154+
155+ void SetLineJoinMode(join_mode mode);
156+ join_mode LineJoinMode() const
157+ { return fLineJoinMode; }
158+
159+ void SetMiterLimit(float limit);
160+ float MiterLimit() const
161+ { return fMiterLimit; }
162+
163+ void SetFillRule(int32 fillRule);
164+ int32 FillRule() const
165+ { return fFillRule; }
166+
167+ // convenience functions
168+ void PrintToStream() const;
169+
170+ void SetSubPixelPrecise(bool precise);
171+ bool SubPixelPrecise() const
172+ { return fSubPixelPrecise; }
173+
174+protected:
175+ BPoint fOrigin;
176+ BPoint fCombinedOrigin;
177+ float fScale;
178+ float fCombinedScale;
179+ BAffineTransform fTransform;
180+ BAffineTransform fCombinedTransform;
181+
182+ ObjectDeleter<BRegion>
183+ fClippingRegion;
184+
185+ BReference<AlphaMask> fAlphaMask;
186+
187+ rgb_color fHighColor;
188+ rgb_color fLowColor;
189+
190+ color_which fWhichHighColor;
191+ color_which fWhichLowColor;
192+ float fWhichHighColorTint;
193+ float fWhichLowColorTint;
194+ Pattern fPattern;
195+
196+ drawing_mode fDrawingMode;
197+ source_alpha fAlphaSrcMode;
198+ alpha_function fAlphaFncMode;
199+ bool fDrawingModeLocked;
200+
201+ BPoint fPenLocation;
202+ float fPenSize;
203+
204+ ServerFont fFont;
205+ // overrides font aliasing flag
206+ bool fFontAliasing;
207+
208+ // This is not part of the normal state stack.
209+ // The view will update it in PushState/PopState.
210+ // A BView can have a flag "B_SUBPIXEL_PRECISE",
211+ // I never knew what it does on R5, but I can use
212+ // it in Painter to actually draw stuff with
213+ // sub-pixel coordinates. It means
214+ // StrokeLine(BPoint(10, 5), BPoint(20, 9));
215+ // will look different from
216+ // StrokeLine(BPoint(10.3, 5.8), BPoint(20.6, 9.5));
217+ bool fSubPixelPrecise;
218+
219+ cap_mode fLineCapMode;
220+ join_mode fLineJoinMode;
221+ float fMiterLimit;
222+ int32 fFillRule;
223+ // "internal", used to calculate the size
224+ // of the font (again) when the scale changes
225+ float fUnscaledFontSize;
226+
227+ ObjectDeleter<DrawState>
228+ fPreviousState;
229+};
230+
231+#endif // _DRAW_STATE_H_
+218,
-0
1@@ -0,0 +1,218 @@
2+/*
3+ * Copyright 2001-2018, Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Gabe Yoder <gyoder@stny.rr.com>
9+ * Stephan Aßmus <superstippi@gmx.de>
10+ * Julian Harnath <julian.harnath@rwth-aachen.de>
11+ */
12+#ifndef DRAWING_ENGINE_H_
13+#define DRAWING_ENGINE_H_
14+
15+
16+#include <AutoDeleter.h>
17+#include <Accelerant.h>
18+#include <Font.h>
19+#include <Locker.h>
20+#include <Point.h>
21+#include <Gradient.h>
22+#include <ServerProtocolStructs.h>
23+
24+#include "HWInterface.h"
25+
26+
27+class BPoint;
28+class BRect;
29+class BRegion;
30+
31+class DrawState;
32+class Painter;
33+class ServerBitmap;
34+class ServerCursor;
35+class ServerFont;
36+
37+
38+class DrawingEngine : public HWInterfaceListener {
39+public:
40+ DrawingEngine(HWInterface* interface = NULL);
41+ virtual ~DrawingEngine();
42+
43+ // HWInterfaceListener interface
44+ virtual void FrameBufferChanged();
45+
46+ // for "changing" hardware
47+ void SetHWInterface(HWInterface* interface);
48+
49+ virtual void SetCopyToFrontEnabled(bool enable);
50+ bool CopyToFrontEnabled() const
51+ { return fCopyToFront; }
52+ virtual void CopyToFront(/*const*/ BRegion& region);
53+
54+ // locking
55+ bool LockParallelAccess();
56+#if DEBUG
57+ virtual bool IsParallelAccessLocked() const;
58+#endif
59+ void UnlockParallelAccess();
60+
61+ bool LockExclusiveAccess();
62+ virtual bool IsExclusiveAccessLocked() const;
63+ void UnlockExclusiveAccess();
64+
65+ // for screen shots
66+ ServerBitmap* DumpToBitmap();
67+ virtual status_t ReadBitmap(ServerBitmap *bitmap, bool drawCursor,
68+ BRect bounds);
69+
70+ // clipping for all drawing functions, passing a NULL region
71+ // will remove any clipping (drawing allowed everywhere)
72+ virtual void ConstrainClippingRegion(const BRegion* region);
73+
74+ virtual void SetDrawState(const DrawState* state,
75+ int32 xOffset = 0, int32 yOffset = 0);
76+
77+ virtual void SetHighColor(const rgb_color& color);
78+ virtual void SetLowColor(const rgb_color& color);
79+ virtual void SetPenSize(float size);
80+ virtual void SetStrokeMode(cap_mode lineCap, join_mode joinMode,
81+ float miterLimit);
82+ virtual void SetFillRule(int32 fillRule);
83+ virtual void SetPattern(const struct pattern& pattern);
84+ virtual void SetDrawingMode(drawing_mode mode);
85+ virtual void SetDrawingMode(drawing_mode mode,
86+ drawing_mode& oldMode);
87+ virtual void SetBlendingMode(source_alpha srcAlpha,
88+ alpha_function alphaFunc);
89+ virtual void SetFont(const ServerFont& font);
90+ virtual void SetFont(const DrawState* state);
91+ virtual void SetTransform(const BAffineTransform& transform,
92+ int32 xOffset, int32 yOffset);
93+
94+ void SuspendAutoSync();
95+ void Sync();
96+
97+ // drawing functions
98+ virtual void CopyRegion(/*const*/ BRegion* region,
99+ int32 xOffset, int32 yOffset);
100+
101+ virtual void InvertRect(BRect r);
102+
103+ virtual void DrawBitmap(ServerBitmap* bitmap,
104+ const BRect& bitmapRect, const BRect& viewRect,
105+ uint32 options = 0);
106+ // drawing primitives
107+ virtual void DrawArc(BRect r, const float& angle,
108+ const float& span, bool filled);
109+ virtual void FillArc(BRect r, const float& angle,
110+ const float& span, const BGradient& gradient);
111+
112+ virtual void DrawBezier(BPoint* pts, bool filled);
113+ virtual void FillBezier(BPoint* pts, const BGradient& gradient);
114+
115+ virtual void DrawEllipse(BRect r, bool filled);
116+ virtual void FillEllipse(BRect r, const BGradient& gradient);
117+
118+ virtual void DrawPolygon(BPoint* ptlist, int32 numpts,
119+ BRect bounds, bool filled, bool closed);
120+ virtual void FillPolygon(BPoint* ptlist, int32 numpts,
121+ BRect bounds, const BGradient& gradient,
122+ bool closed);
123+
124+ // these rgb_color versions are used internally by the server
125+ virtual void StrokePoint(const BPoint& point,
126+ const rgb_color& color);
127+ virtual void StrokeRect(BRect rect, const rgb_color &color);
128+ virtual void FillRect(BRect rect, const rgb_color &color);
129+ virtual void FillRegion(BRegion& region, const rgb_color& color);
130+
131+ virtual void StrokeRect(BRect rect);
132+ virtual void FillRect(BRect rect);
133+ virtual void FillRect(BRect rect, const BGradient& gradient);
134+
135+ virtual void FillRegion(BRegion& region);
136+ virtual void FillRegion(BRegion& region,
137+ const BGradient& gradient);
138+
139+ virtual void DrawRoundRect(BRect rect, float xrad,
140+ float yrad, bool filled);
141+ virtual void FillRoundRect(BRect rect, float xrad,
142+ float yrad, const BGradient& gradient);
143+
144+ virtual void DrawShape(const BRect& bounds,
145+ int32 opcount, const uint32* oplist,
146+ int32 ptcount, const BPoint* ptlist,
147+ bool filled, const BPoint& viewToScreenOffset,
148+ float viewScale);
149+ virtual void FillShape(const BRect& bounds,
150+ int32 opcount, const uint32* oplist,
151+ int32 ptcount, const BPoint* ptlist,
152+ const BGradient& gradient,
153+ const BPoint& viewToScreenOffset,
154+ float viewScale);
155+
156+ virtual void DrawTriangle(BPoint* points, const BRect& bounds,
157+ bool filled);
158+ virtual void FillTriangle(BPoint* points, const BRect& bounds,
159+ const BGradient& gradient);
160+
161+ // these versions are used by the Decorator
162+ virtual void StrokeLine(const BPoint& start,
163+ const BPoint& end, const rgb_color& color);
164+
165+ virtual void StrokeLine(const BPoint& start,
166+ const BPoint& end);
167+
168+ virtual void StrokeLineArray(int32 numlines,
169+ const ViewLineArrayInfo* data);
170+
171+ // -------- text related calls
172+
173+ // returns the pen position behind the (virtually) drawn
174+ // string
175+ virtual BPoint DrawString(const char* string, int32 length,
176+ const BPoint& pt,
177+ escapement_delta* delta = NULL);
178+ virtual BPoint DrawString(const char* string, int32 length,
179+ const BPoint* offsets);
180+
181+ float StringWidth(const char* string, int32 length,
182+ escapement_delta* delta = NULL);
183+
184+ // convenience function which is independent of graphics
185+ // state (to be used by Decorator or ServerApp etc)
186+ float StringWidth(const char* string,
187+ int32 length, const ServerFont& font,
188+ escapement_delta* delta = NULL);
189+
190+ BPoint DrawStringDry(const char* string, int32 length,
191+ const BPoint& pt,
192+ escapement_delta* delta = NULL);
193+ BPoint DrawStringDry(const char* string, int32 length,
194+ const BPoint* offsets);
195+
196+
197+ // software rendering backend invoked by CopyRegion() for the sorted
198+ // individual rects
199+ virtual BRect CopyRect(BRect rect, int32 xOffset,
200+ int32 yOffset) const;
201+
202+ void SetRendererOffset(int32 offsetX, int32 offsetY);
203+
204+private:
205+ friend class DrawTransaction;
206+
207+ void _CopyRect(uint8* bits, uint32 width,
208+ uint32 height, uint32 bytesPerRow,
209+ int32 xOffset, int32 yOffset) const;
210+
211+ ObjectDeleter<Painter>
212+ fPainter;
213+ HWInterface* fGraphicsCard;
214+ uint32 fAvailableHWAccleration;
215+ int32 fSuspendSyncLevel;
216+ bool fCopyToFront;
217+};
218+
219+#endif // DRAWING_ENGINE_H_
1@@ -0,0 +1,162 @@
2+/*
3+ * Copyright 2005-2007, Haiku, Inc. All Rights Reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef EVENT_DISPATCHER_H
10+#define EVENT_DISPATCHER_H
11+
12+
13+#include <AutoDeleter.h>
14+#include <Locker.h>
15+#include <Message.h>
16+#include <MessageFilter.h>
17+#include <Messenger.h>
18+#include <ObjectList.h>
19+
20+
21+class Desktop;
22+class EventStream;
23+class HWInterface;
24+class ServerBitmap;
25+
26+struct event_listener;
27+
28+
29+class EventTarget {
30+ public:
31+ EventTarget();
32+ ~EventTarget();
33+
34+ void SetTo(const BMessenger& messenger);
35+ BMessenger& Messenger() { return fMessenger; }
36+
37+ event_listener* FindListener(int32 token, int32* _index = NULL);
38+ bool AddListener(int32 token, uint32 eventMask, uint32 options,
39+ bool temporary);
40+ void RemoveListener(event_listener* listener, bool temporary);
41+
42+ bool RemoveListener(int32 token);
43+ bool RemoveTemporaryListener(int32 token);
44+ void RemoveTemporaryListeners();
45+
46+ bool IsEmpty() const { return fListeners.IsEmpty(); }
47+
48+ int32 CountListeners() const { return fListeners.CountItems(); }
49+ event_listener* ListenerAt(int32 index) const
50+ { return fListeners.ItemAt(index); }
51+
52+ private:
53+ bool _RemoveTemporaryListener(event_listener* listener, int32 index);
54+
55+ BObjectList<event_listener> fListeners;
56+ BMessenger fMessenger;
57+};
58+
59+class EventFilter {
60+ public:
61+ virtual ~EventFilter() {};
62+ virtual filter_result Filter(BMessage* event, EventTarget** _target,
63+ int32* _viewToken = NULL, BMessage* latestMouseMoved = NULL) = 0;
64+ virtual void RemoveTarget(EventTarget* target);
65+};
66+
67+class EventDispatcher : public BLocker {
68+ public:
69+ EventDispatcher();
70+ ~EventDispatcher();
71+
72+ status_t SetTo(EventStream* stream);
73+ status_t InitCheck();
74+
75+ void RemoveTarget(EventTarget& target);
76+
77+ bool AddListener(EventTarget& target, int32 token,
78+ uint32 eventMask, uint32 options);
79+ bool AddTemporaryListener(EventTarget& target,
80+ int32 token, uint32 eventMask, uint32 options);
81+ void RemoveListener(EventTarget& target, int32 token);
82+ void RemoveTemporaryListener(EventTarget& target, int32 token);
83+
84+ void SetMouseFilter(EventFilter* filter);
85+ void SetKeyboardFilter(EventFilter* filter);
86+
87+ void GetMouse(BPoint& where, int32& buttons);
88+ void SendFakeMouseMoved(EventTarget& target, int32 viewToken);
89+ bigtime_t IdleTime();
90+
91+ bool HasCursorThread();
92+ void SetHWInterface(HWInterface* interface);
93+
94+ void SetDragMessage(BMessage& message, ServerBitmap* bitmap,
95+ const BPoint& offsetFromCursor);
96+ // the message should be delivered on the next
97+ // "mouse up".
98+ // if the mouse is not pressed, it should
99+ // be delivered to the "current" target right away.
100+
101+ void SetDesktop(Desktop* desktop);
102+
103+ private:
104+ status_t _Run();
105+ void _Unset();
106+
107+ void _SendFakeMouseMoved(BMessage* message);
108+ bool _SendMessage(BMessenger& messenger, BMessage* message,
109+ float importance);
110+
111+ bool _AddTokens(BMessage* message, EventTarget* target,
112+ uint32 eventMask, BMessage* nextMouseMoved = NULL,
113+ int32* _viewToken = NULL);
114+ void _RemoveTokens(BMessage* message);
115+ void _SetFeedFocus(BMessage* message);
116+ void _UnsetFeedFocus(BMessage* message);
117+
118+ void _SetMouseTarget(const BMessenger* messenger);
119+ void _UnsetLastMouseTarget();
120+
121+ bool _AddListener(EventTarget& target, int32 token,
122+ uint32 eventMask, uint32 options, bool temporary);
123+ void _RemoveTemporaryListeners();
124+
125+ void _DeliverDragMessage();
126+
127+ void _EventLoop();
128+ void _CursorLoop();
129+
130+ static status_t _event_looper(void* dispatcher);
131+ static status_t _cursor_looper(void* dispatcher);
132+
133+ private:
134+ EventStream* fStream;
135+ thread_id fThread;
136+ thread_id fCursorThread;
137+
138+ EventTarget* fPreviousMouseTarget;
139+ EventTarget* fFocus;
140+ bool fSuspendFocus;
141+
142+ ObjectDeleter <EventFilter>
143+ fMouseFilter;
144+ ObjectDeleter<EventFilter>
145+ fKeyboardFilter;
146+
147+ BObjectList<EventTarget> fTargets;
148+
149+ BMessage* fNextLatestMouseMoved;
150+ BPoint fLastCursorPosition;
151+ int32 fLastButtons;
152+ bigtime_t fLastUpdate;
153+
154+ BMessage fDragMessage;
155+ bool fDraggingMessage;
156+ BPoint fDragOffset;
157+
158+ BLocker fCursorLock;
159+ HWInterface* fHWInterface;
160+ Desktop* fDesktop;
161+};
162+
163+#endif /* EVENT_DISPATCHER_H */
+58,
-0
1@@ -0,0 +1,58 @@
2+/*
3+ * Copyright 2001-2008, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Axel Dörfler, axeld@pinc-software.de
9+ */
10+#ifndef FONT_FAMILY_H_
11+#define FONT_FAMILY_H_
12+
13+
14+#include <ObjectList.h>
15+#include <String.h>
16+
17+#include "FontStyle.h"
18+
19+
20+/*!
21+ \class FontFamily FontFamily.h
22+ \brief Class representing a collection of similar styles
23+
24+ FontFamily objects bring together many styles of the same face, such as
25+ Arial Roman, Arial Italic, Arial Bold, etc.
26+*/
27+class FontFamily {
28+public:
29+ FontFamily(const char* name, uint16 id);
30+ virtual ~FontFamily();
31+
32+ const char* Name() const;
33+
34+ bool AddStyle(FontStyle* style);
35+ bool RemoveStyle(FontStyle* style);
36+
37+ FontStyle* GetStyle(const char* style) const;
38+ FontStyle* GetStyleMatchingFace(uint16 face) const;
39+ FontStyle* GetStyleByID(uint16 face) const;
40+
41+ uint16 ID() const
42+ { return fID; }
43+ uint32 Flags();
44+
45+ bool HasStyle(const char* style) const;
46+ int32 CountStyles() const;
47+ FontStyle* StyleAt(int32 index) const;
48+
49+private:
50+ FontStyle* _FindStyle(const char* name) const;
51+
52+ BString fName;
53+ BObjectList<FontStyle> fStyles;
54+ uint16 fID;
55+ uint16 fNextID;
56+ uint32 fFlags;
57+};
58+
59+#endif // FONT_FAMILY_H_
+161,
-0
1@@ -0,0 +1,161 @@
2+/*
3+ * Copyright 2001-2009, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Axel Dörfler, axeld@pinc-software.de
9+ */
10+#ifndef FONT_MANAGER_H
11+#define FONT_MANAGER_H
12+
13+
14+#include <AutoDeleter.h>
15+#include <HashMap.h>
16+#include <Looper.h>
17+#include <ObjectList.h>
18+#include <Referenceable.h>
19+
20+#include <ft2build.h>
21+#include FT_FREETYPE_H
22+
23+class BEntry;
24+class BPath;
25+struct node_ref;
26+
27+class FontFamily;
28+class FontStyle;
29+class ServerFont;
30+
31+
32+/*!
33+ \class FontManager FontManager.h
34+ \brief Manager for the largest part of the font subsystem
35+*/
36+class FontManager : public BLooper {
37+public:
38+ FontManager();
39+ virtual ~FontManager();
40+
41+ status_t InitCheck() { return fInitStatus; }
42+ void SaveRecentFontMappings();
43+
44+ virtual void MessageReceived(BMessage* message);
45+
46+ int32 CheckRevision(uid_t user);
47+ int32 CountFamilies();
48+
49+ int32 CountStyles(const char* family);
50+ int32 CountStyles(uint16 familyID);
51+ FontFamily* FamilyAt(int32 index) const;
52+
53+ FontFamily* GetFamily(uint16 familyID) const;
54+ FontFamily* GetFamily(const char* name);
55+
56+ FontStyle* GetStyleByIndex(const char* family,
57+ int32 index);
58+ FontStyle* GetStyleByIndex(uint16 familyID, int32 index);
59+ FontStyle* GetStyle(const char* family, const char* style,
60+ uint16 familyID = 0xffff,
61+ uint16 styleID = 0xffff, uint16 face = 0);
62+ FontStyle* GetStyle(const char *family, uint16 styleID);
63+ FontStyle* GetStyle(uint16 familyID,
64+ uint16 styleID) const;
65+ FontStyle* FindStyleMatchingFace(uint16 face) const;
66+
67+ void RemoveStyle(FontStyle* style);
68+ // This call must not be used by anything else than class
69+ // FontStyle.
70+
71+ const ServerFont* DefaultPlainFont() const;
72+ const ServerFont* DefaultBoldFont() const;
73+ const ServerFont* DefaultFixedFont() const;
74+
75+ void AttachUser(uid_t userID);
76+ void DetachUser(uid_t userID);
77+
78+private:
79+ struct font_directory;
80+ struct font_mapping;
81+
82+ void _AddDefaultMapping(const char* family,
83+ const char* style, const char* path);
84+ bool _LoadRecentFontMappings();
85+ status_t _AddMappedFont(const char* family,
86+ const char* style = NULL);
87+ FontStyle* _GetDefaultStyle(const char* familyName,
88+ const char* styleName,
89+ const char* fallbackFamily,
90+ const char* fallbackStyle,
91+ uint16 fallbackFace);
92+ status_t _SetDefaultFonts();
93+ void _PrecacheFontFile(const ServerFont* font);
94+ void _AddSystemPaths();
95+ font_directory* _FindDirectory(node_ref& nodeRef);
96+ void _RemoveDirectory(font_directory* directory);
97+ status_t _CreateDirectories(const char* path);
98+ status_t _AddPath(const char* path);
99+ status_t _AddPath(BEntry& entry,
100+ font_directory** _newDirectory = NULL);
101+
102+ void _RemoveStyle(font_directory& directory,
103+ FontStyle* style);
104+ void _RemoveStyle(dev_t device, uint64 directory,
105+ uint64 node);
106+ FontFamily* _FindFamily(const char* family) const;
107+
108+ void _ScanFontsIfNecessary();
109+ void _ScanFonts();
110+ status_t _ScanFontDirectory(font_directory& directory);
111+ status_t _AddFont(font_directory& directory,
112+ BEntry& entry);
113+
114+ FT_CharMap _GetSupportedCharmap(const FT_Face& face);
115+
116+private:
117+ struct FontKey {
118+ FontKey(uint16 family, uint16 style)
119+ : familyID(family), styleID(style) {}
120+
121+ uint32 GetHashCode() const
122+ {
123+ return familyID | (styleID << 16UL);
124+ }
125+
126+ bool operator==(const FontKey& other) const
127+ {
128+ return familyID == other.familyID
129+ && styleID == other.styleID;
130+ }
131+
132+ uint16 familyID, styleID;
133+ };
134+
135+private:
136+ status_t fInitStatus;
137+
138+ typedef BObjectList<font_directory> DirectoryList;
139+ typedef BObjectList<font_mapping> MappingList;
140+ typedef BObjectList<FontFamily> FamilyList;
141+
142+ DirectoryList fDirectories;
143+ MappingList fMappings;
144+ FamilyList fFamilies;
145+
146+ HashMap<FontKey, BReference<FontStyle> > fStyleHashTable;
147+
148+ ObjectDeleter<ServerFont>
149+ fDefaultPlainFont;
150+ ObjectDeleter<ServerFont>
151+ fDefaultBoldFont;
152+ ObjectDeleter<ServerFont>
153+ fDefaultFixedFont;
154+
155+ bool fScanned;
156+ int32 fNextID;
157+};
158+
159+extern FT_Library gFreeTypeLibrary;
160+extern FontManager* gFontManager;
161+
162+#endif /* FONT_MANAGER_H */
+155,
-0
1@@ -0,0 +1,155 @@
2+/*
3+ * Copyright 2001-2008, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Axel Dörfler, axeld@pinc-software.de
9+ */
10+#ifndef FONT_STYLE_H_
11+#define FONT_STYLE_H_
12+
13+
14+#include <Font.h>
15+#include <Locker.h>
16+#include <Node.h>
17+#include <ObjectList.h>
18+#include <Path.h>
19+#include <Rect.h>
20+#include <Referenceable.h>
21+#include <String.h>
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+
27+struct node_ref;
28+class FontFamily;
29+class ServerFont;
30+
31+
32+/*!
33+ \class FontStyle FontStyle.h
34+ \brief Object used to represent a font style
35+
36+ FontStyle objects help abstract a lot of the font engine details while
37+ still offering plenty of information the style in question.
38+*/
39+class FontStyle : public BReferenceable {
40+ public:
41+ FontStyle(node_ref& nodeRef, const char* path,
42+ FT_Face face);
43+ virtual ~FontStyle();
44+
45+ const node_ref& NodeRef() const { return fNodeRef; }
46+
47+ bool Lock();
48+ void Unlock();
49+
50+/*!
51+ \fn bool FontStyle::IsFixedWidth(void)
52+ \brief Determines whether the font's character width is fixed
53+ \return true if fixed, false if not
54+*/
55+ bool IsFixedWidth() const
56+ { return FT_IS_FIXED_WIDTH(fFreeTypeFace); }
57+
58+
59+/* \fn bool FontStyle::IsFullAndHalfFixed()
60+ \brief Determines whether the font has 2 different, fixed, widths.
61+ \return false (for now)
62+*/
63+ bool IsFullAndHalfFixed() const
64+ { return fFullAndHalfFixed; };
65+
66+/*!
67+ \fn bool FontStyle::IsScalable(void)
68+ \brief Determines whether the font can be scaled to any size
69+ \return true if scalable, false if not
70+*/
71+ bool IsScalable() const
72+ { return FT_IS_SCALABLE(fFreeTypeFace); }
73+/*!
74+ \fn bool FontStyle::HasKerning(void)
75+ \brief Determines whether the font has kerning information
76+ \return true if kerning info is available, false if not
77+*/
78+ bool HasKerning() const
79+ { return FT_HAS_KERNING(fFreeTypeFace); }
80+/*!
81+ \fn bool FontStyle::HasTuned(void)
82+ \brief Determines whether the font contains strikes
83+ \return true if it has strikes included, false if not
84+*/
85+ bool HasTuned() const
86+ { return FT_HAS_FIXED_SIZES(fFreeTypeFace); }
87+/*!
88+ \fn bool FontStyle::TunedCount(void)
89+ \brief Returns the number of strikes the style contains
90+ \return The number of strikes the style contains
91+*/
92+ int32 TunedCount() const
93+ { return fFreeTypeFace->num_fixed_sizes; }
94+/*!
95+ \fn bool FontStyle::GlyphCount(void)
96+ \brief Returns the number of glyphs in the style
97+ \return The number of glyphs the style contains
98+*/
99+ uint16 GlyphCount() const
100+ { return fFreeTypeFace->num_glyphs; }
101+/*!
102+ \fn bool FontStyle::CharMapCount(void)
103+ \brief Returns the number of character maps the style contains
104+ \return The number of character maps the style contains
105+*/
106+ uint16 CharMapCount() const
107+ { return fFreeTypeFace->num_charmaps; }
108+
109+ const char* Name() const
110+ { return fName.String(); }
111+ FontFamily* Family() const
112+ { return fFamily; }
113+ uint16 ID() const
114+ { return fID; }
115+ uint32 Flags() const;
116+
117+ uint16 Face() const
118+ { return fFace; }
119+ uint16 PreservedFace(uint16) const;
120+
121+ const char* Path() const;
122+ void UpdatePath(const node_ref& parentNodeRef);
123+
124+ void GetHeight(float size, font_height &heigth) const;
125+ font_direction Direction() const
126+ { return B_FONT_LEFT_TO_RIGHT; }
127+ font_file_format FileFormat() const
128+ { return B_TRUETYPE_WINDOWS; }
129+
130+ FT_Face FreeTypeFace() const
131+ { return fFreeTypeFace; }
132+
133+ status_t UpdateFace(FT_Face face);
134+
135+ private:
136+ friend class FontFamily;
137+ uint16 _TranslateStyleToFace(const char *name) const;
138+ void _SetFontFamily(FontFamily* family, uint16 id);
139+
140+ private:
141+ FT_Face fFreeTypeFace;
142+ BString fName;
143+ BPath fPath;
144+ node_ref fNodeRef;
145+
146+ FontFamily* fFamily;
147+ uint16 fID;
148+
149+ BRect fBounds;
150+
151+ font_height fHeight;
152+ uint16 fFace;
153+ bool fFullAndHalfFixed;
154+};
155+
156+#endif // FONT_STYLE_H_
1@@ -0,0 +1,35 @@
2+/*
3+ * Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
4+ * All rights reserved. Distributed under the terms of the MIT License.
5+ */
6+#ifndef GLOBAL_SUBPIXEL_SETTINGS_H
7+#define GLOBAL_SUBPIXEL_SETTINGS_H
8+
9+#include <SupportDefs.h>
10+
11+// TODO: these global settings need to be removed - once we have more than one
12+// user, we also must support more than one setting. That's why there is a
13+// DesktopSettings class in the first place...
14+
15+enum {
16+ HINTING_MODE_OFF = 0,
17+ HINTING_MODE_ON,
18+ HINTING_MODE_MONOSPACED_ONLY
19+};
20+
21+//#define AVERAGE_BASED_SUBPIXEL_FILTERING
22+
23+extern bool gSubpixelAntialiasing;
24+extern uint8 gDefaultHintingMode;
25+
26+// The weight with which the average of the subpixels is applied to counter
27+// color fringes (0 = full sharpness ... 255 = grayscale anti-aliasing)
28+extern uint8 gSubpixelAverageWeight;
29+
30+// There are two types of LCD displays in general - the more common have
31+// sub - pixels physically ordered as RGB within a pixel, but some are BGR.
32+// Sub - pixel antialiasing optimised for one ordering obviously doesn't work
33+// on the other.
34+extern bool gSubpixelOrderingRGB;
35+
36+#endif // GLOBAL_SUBPIXEL_SETTINGS_H
+281,
-0
1@@ -0,0 +1,281 @@
2+/*
3+ * Copyright 2005-2012, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus <superstippi@gmx.de>
8+ */
9+#ifndef HW_INTERFACE_H
10+#define HW_INTERFACE_H
11+
12+
13+#include <AutoDeleter.h>
14+#include <Accelerant.h>
15+#include <GraphicsCard.h>
16+#include <List.h>
17+#include <Locker.h>
18+#include <OS.h>
19+#include <Region.h>
20+
21+#include <video_overlay.h>
22+
23+#include <new>
24+
25+#include "IntRect.h"
26+#include "MultiLocker.h"
27+#include "ServerCursor.h"
28+
29+
30+class BString;
31+class DrawingEngine;
32+class EventStream;
33+class Overlay;
34+class RenderingBuffer;
35+class ServerBitmap;
36+class UpdateQueue;
37+
38+
39+enum {
40+ HW_ACC_COPY_REGION = 0x00000001,
41+ HW_ACC_FILL_REGION = 0x00000002,
42+ HW_ACC_INVERT_REGION = 0x00000004,
43+};
44+
45+
46+class HWInterfaceListener {
47+public:
48+ HWInterfaceListener();
49+ virtual ~HWInterfaceListener();
50+
51+ virtual void FrameBufferChanged() {};
52+ // Informs a downstream DrawingEngine of a changed framebuffer.
53+
54+ virtual void ScreenChanged(HWInterface* interface) {};
55+ // Informs an upstream client of a changed screen configuration.
56+};
57+
58+
59+class HWInterface : protected MultiLocker {
60+public:
61+ HWInterface(bool doubleBuffered = false,
62+ bool enableUpdateQueue = true);
63+ virtual ~HWInterface();
64+
65+ // locking
66+ bool LockParallelAccess() { return ReadLock(); }
67+#if DEBUG
68+ bool IsParallelAccessLocked() const
69+ { return IsReadLocked(); }
70+#endif
71+ void UnlockParallelAccess() { ReadUnlock(); }
72+
73+ bool LockExclusiveAccess() { return WriteLock(); }
74+ bool IsExclusiveAccessLocked()
75+ { return IsWriteLocked(); }
76+ void UnlockExclusiveAccess() { WriteUnlock(); }
77+
78+ // You need to WriteLock
79+ virtual status_t Initialize();
80+ virtual status_t Shutdown() = 0;
81+
82+ // allocating a DrawingEngine attached to this HWInterface
83+ virtual DrawingEngine* CreateDrawingEngine();
84+
85+ // creating an event stream specific for this HWInterface
86+ // returns NULL when there is no specific event stream necessary
87+ virtual EventStream* CreateEventStream();
88+
89+ // screen mode stuff
90+ virtual status_t SetMode(const display_mode& mode) = 0;
91+ virtual void GetMode(display_mode* mode) = 0;
92+
93+ virtual status_t GetDeviceInfo(accelerant_device_info* info) = 0;
94+ virtual status_t GetFrameBufferConfig(
95+ frame_buffer_config& config) = 0;
96+ virtual status_t GetModeList(display_mode** _modeList,
97+ uint32* _count) = 0;
98+ virtual status_t GetPixelClockLimits(display_mode* mode,
99+ uint32* _low, uint32* _high) = 0;
100+ virtual status_t GetTimingConstraints(display_timing_constraints*
101+ constraints) = 0;
102+ virtual status_t ProposeMode(display_mode* candidate,
103+ const display_mode* low,
104+ const display_mode* high) = 0;
105+ virtual status_t GetPreferredMode(display_mode* mode);
106+ virtual status_t GetMonitorInfo(monitor_info* info);
107+
108+ virtual sem_id RetraceSemaphore() = 0;
109+ virtual status_t WaitForRetrace(
110+ bigtime_t timeout = B_INFINITE_TIMEOUT) = 0;
111+
112+ virtual status_t SetDPMSMode(uint32 state) = 0;
113+ virtual uint32 DPMSMode() = 0;
114+ virtual uint32 DPMSCapabilities() = 0;
115+
116+ virtual status_t SetBrightness(float) = 0;
117+ virtual status_t GetBrightness(float*) = 0;
118+
119+ virtual status_t GetAccelerantPath(BString& path);
120+ virtual status_t GetDriverPath(BString& path);
121+
122+ // query for available hardware accleration and perform it
123+ // (Initialize() must have been called already)
124+ virtual uint32 AvailableHWAcceleration() const
125+ { return 0; }
126+
127+ virtual void CopyRegion(const clipping_rect* sortedRectList,
128+ uint32 count, int32 xOffset, int32 yOffset)
129+ {}
130+ virtual void FillRegion(/*const*/ BRegion& region,
131+ const rgb_color& color, bool autoSync) {}
132+ virtual void InvertRegion(/*const*/ BRegion& region) {}
133+
134+ virtual void Sync() {}
135+
136+ // cursor handling (these do their own Read/Write locking)
137+ ServerCursorReference Cursor() const;
138+ ServerCursorReference CursorAndDragBitmap() const;
139+ virtual void SetCursor(ServerCursor* cursor);
140+ virtual void SetCursorVisible(bool visible);
141+ bool IsCursorVisible();
142+ virtual void ObscureCursor();
143+ virtual void MoveCursorTo(float x, float y);
144+ BPoint CursorPosition();
145+
146+ virtual void SetDragBitmap(const ServerBitmap* bitmap,
147+ const BPoint& offsetFromCursor);
148+
149+ // overlay support
150+ virtual overlay_token AcquireOverlayChannel();
151+ virtual void ReleaseOverlayChannel(overlay_token token);
152+
153+ virtual status_t GetOverlayRestrictions(const Overlay* overlay,
154+ overlay_restrictions* restrictions);
155+ virtual bool CheckOverlayRestrictions(int32 width,
156+ int32 height, color_space colorSpace);
157+ virtual const overlay_buffer* AllocateOverlayBuffer(int32 width,
158+ int32 height, color_space space);
159+ virtual void FreeOverlayBuffer(const overlay_buffer* buffer);
160+
161+ virtual void ConfigureOverlay(Overlay* overlay);
162+ virtual void HideOverlay(Overlay* overlay);
163+
164+ // frame buffer access (you need to ReadLock!)
165+ RenderingBuffer* DrawingBuffer() const;
166+ virtual RenderingBuffer* FrontBuffer() const = 0;
167+ virtual RenderingBuffer* BackBuffer() const = 0;
168+ void SetAsyncDoubleBuffered(bool doubleBuffered);
169+ virtual bool IsDoubleBuffered() const;
170+
171+ // Invalidate is used for scheduling an area for updating
172+ virtual status_t InvalidateRegion(const BRegion& region);
173+ virtual status_t Invalidate(const BRect& frame);
174+ // while as CopyBackToFront() actually performs the operation
175+ // either directly or asynchronously by the UpdateQueue thread
176+ virtual status_t CopyBackToFront(const BRect& frame);
177+
178+protected:
179+ virtual void _CopyBackToFront(/*const*/ BRegion& region);
180+
181+public:
182+ // TODO: Just a quick and primitive way to get single buffered mode working.
183+ // Later, the implementation should be smarter, right now, it will
184+ // draw the cursor for almost every drawing operation.
185+ // It seems to me BeOS hides the cursor (in laymans words) before
186+ // BView::Draw() is called (if the cursor is within that views clipping region),
187+ // then, after all drawing commands that triggered have been caried out,
188+ // it shows the cursor again. This approach would have the advantage of
189+ // the code not cluttering/slowing down DrawingEngine.
190+ // For now, we hide the cursor for any drawing operation that has
191+ // a bounding box containing the cursor (in DrawingEngine) so
192+ // the cursor hiding is completely transparent from code using DrawingEngine.
193+ // ---
194+ // NOTE: Investigate locking for these! The client code should already hold a
195+ // ReadLock, but maybe these functions should acquire a WriteLock!
196+ bool HideFloatingOverlays(const BRect& area);
197+ bool HideFloatingOverlays();
198+ void ShowFloatingOverlays();
199+
200+ // Listener support
201+ bool AddListener(HWInterfaceListener* listener);
202+ void RemoveListener(HWInterfaceListener* listener);
203+
204+protected:
205+ // implement this in derived classes
206+ virtual void _DrawCursor(IntRect area) const;
207+
208+ // does the actual transfer and handles color space conversion
209+ void _CopyToFront(uint8* src, uint32 srcBPR, int32 x,
210+ int32 y, int32 right, int32 bottom) const;
211+
212+ IntRect _CursorFrame() const;
213+ void _RestoreCursorArea() const;
214+ void _AdoptDragBitmap();
215+
216+ void _NotifyFrameBufferChanged();
217+ void _NotifyScreenChanged();
218+
219+ static bool _IsValidMode(const display_mode& mode);
220+
221+ // If we draw the cursor somewhere in the drawing buffer,
222+ // we need to backup its contents before drawing, so that
223+ // we can restore that area when the cursor needs to be
224+ // drawn somewhere else.
225+ struct buffer_clip {
226+ buffer_clip(int32 width, int32 height)
227+ {
228+ bpr = width * 4;
229+ if (bpr > 0 && height > 0)
230+ buffer = new(std::nothrow) uint8[bpr * height];
231+ else
232+ buffer = NULL;
233+ left = 0;
234+ top = 0;
235+ right = -1;
236+ bottom = -1;
237+ cursor_hidden = true;
238+ }
239+
240+ ~buffer_clip()
241+ {
242+ delete[] buffer;
243+ }
244+
245+ uint8* buffer;
246+ int32 left;
247+ int32 top;
248+ int32 right;
249+ int32 bottom;
250+ int32 bpr;
251+ bool cursor_hidden;
252+ };
253+
254+ ObjectDeleter<buffer_clip>
255+ fCursorAreaBackup;
256+ mutable BLocker fFloatingOverlaysLock;
257+
258+ ServerCursorReference
259+ fCursor;
260+ BReference<ServerBitmap>
261+ fDragBitmap;
262+ BPoint fDragBitmapOffset;
263+ ServerCursorReference
264+ fCursorAndDragBitmap;
265+ bool fCursorVisible;
266+ bool fCursorObscured;
267+ bool fHardwareCursorEnabled;
268+ BPoint fCursorLocation;
269+
270+ BRect fTrackingRect;
271+
272+ bool fDoubleBuffered;
273+ int fVGADevice;
274+
275+private:
276+ ObjectDeleter<UpdateQueue>
277+ fUpdateExecutor;
278+
279+ BList fListeners;
280+};
281+
282+#endif // HW_INTERFACE_H
+507,
-0
1@@ -0,0 +1,507 @@
2+/*
3+ * Copyright 2004-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4+ * Copyright 2019, Haiku, Inc. All rights reserved.
5+ * Distributed under the terms of the MIT License.
6+ */
7+#ifndef HASH_MAP_H
8+#define HASH_MAP_H
9+
10+#include <OpenHashTable.h>
11+#include <Locker.h>
12+
13+#include "AutoLocker.h"
14+
15+
16+namespace BPrivate {
17+
18+
19+// HashMapElement
20+template<typename Key, typename Value>
21+class HashMapElement {
22+private:
23+ typedef HashMapElement<Key, Value> Element;
24+
25+public:
26+ HashMapElement()
27+ :
28+ fKey(),
29+ fValue(),
30+ fNext(NULL)
31+ {
32+ }
33+
34+ HashMapElement(const Key& key, const Value& value)
35+ :
36+ fKey(key),
37+ fValue(value),
38+ fNext(NULL)
39+ {
40+ }
41+
42+ Key fKey;
43+ Value fValue;
44+ HashMapElement* fNext;
45+};
46+
47+
48+// HashMapTableDefinition
49+template<typename Key, typename Value>
50+struct HashMapTableDefinition {
51+ typedef Key KeyType;
52+ typedef HashMapElement<Key, Value> ValueType;
53+
54+ size_t HashKey(const KeyType& key) const
55+ { return key.GetHashCode(); }
56+ size_t Hash(const ValueType* value) const
57+ { return HashKey(value->fKey); }
58+ bool Compare(const KeyType& key, const ValueType* value) const
59+ { return value->fKey == key; }
60+ ValueType*& GetLink(ValueType* value) const
61+ { return value->fNext; }
62+};
63+
64+
65+// HashMap
66+template<typename Key, typename Value>
67+class HashMap {
68+public:
69+ class Entry {
70+ public:
71+ Entry() {}
72+ Entry(const Key& key, Value value) : key(key), value(value) {}
73+
74+ Key key;
75+ Value value;
76+ };
77+
78+ class Iterator {
79+ private:
80+ typedef HashMapElement<Key, Value> Element;
81+ public:
82+ Iterator(const Iterator& other)
83+ :
84+ fMap(other.fMap),
85+ fIterator(other.fIterator),
86+ fElement(other.fElement)
87+ {
88+ }
89+
90+ bool HasNext() const
91+ {
92+ return fIterator.HasNext();
93+ }
94+
95+ Entry Next()
96+ {
97+ fElement = fIterator.Next();
98+ if (fElement == NULL)
99+ return Entry();
100+
101+ return Entry(fElement->fKey, fElement->fValue);
102+ }
103+
104+ Iterator& operator=(const Iterator& other)
105+ {
106+ fMap = other.fMap;
107+ fIterator = other.fIterator;
108+ fElement = other.fElement;
109+ return *this;
110+ }
111+
112+ private:
113+ Iterator(const HashMap<Key, Value>* map)
114+ :
115+ fMap(map),
116+ fIterator(map->fTable.GetIterator()),
117+ fElement(NULL)
118+ {
119+ }
120+
121+ private:
122+ friend class HashMap<Key, Value>;
123+ typedef BOpenHashTable<HashMapTableDefinition<Key, Value> >
124+ ElementTable;
125+
126+ const HashMap<Key, Value>* fMap;
127+ typename ElementTable::Iterator fIterator;
128+ Element* fElement;
129+ };
130+
131+ HashMap();
132+ ~HashMap();
133+
134+ status_t InitCheck() const;
135+
136+ status_t Put(const Key& key, const Value& value);
137+ Value Remove(const Key& key);
138+ Value Remove(Iterator& it);
139+ void Clear();
140+ Value Get(const Key& key) const;
141+ bool Get(const Key& key, Value*& _value) const;
142+
143+ bool ContainsKey(const Key& key) const;
144+
145+ int32 Size() const;
146+
147+ Iterator GetIterator() const;
148+
149+protected:
150+ typedef BOpenHashTable<HashMapTableDefinition<Key, Value> > ElementTable;
151+ typedef HashMapElement<Key, Value> Element;
152+ friend class Iterator;
153+
154+protected:
155+ ElementTable fTable;
156+};
157+
158+
159+// SynchronizedHashMap
160+template<typename Key, typename Value, typename Locker = BLocker>
161+class SynchronizedHashMap : public Locker {
162+public:
163+ typedef typename HashMap<Key, Value>::Entry Entry;
164+ typedef typename HashMap<Key, Value>::Iterator Iterator;
165+
166+ SynchronizedHashMap() : Locker("synchronized hash map") {}
167+ ~SynchronizedHashMap() { Locker::Lock(); }
168+
169+ status_t InitCheck() const
170+ {
171+ return fMap.InitCheck();
172+ }
173+
174+ status_t Put(const Key& key, const Value& value)
175+ {
176+ MapLocker locker(this);
177+ if (!locker.IsLocked())
178+ return B_ERROR;
179+ return fMap.Put(key, value);
180+ }
181+
182+ Value Remove(const Key& key)
183+ {
184+ MapLocker locker(this);
185+ if (!locker.IsLocked())
186+ return Value();
187+ return fMap.Remove(key);
188+ }
189+
190+ Value Remove(Iterator& it)
191+ {
192+ MapLocker locker(this);
193+ if (!locker.IsLocked())
194+ return Value();
195+ return fMap.Remove(it);
196+ }
197+
198+ void Clear()
199+ {
200+ MapLocker locker(this);
201+ fMap.Clear();
202+ }
203+
204+ Value Get(const Key& key) const
205+ {
206+ const Locker* lock = this;
207+ MapLocker locker(const_cast<Locker*>(lock));
208+ if (!locker.IsLocked())
209+ return Value();
210+ return fMap.Get(key);
211+ }
212+
213+ bool ContainsKey(const Key& key) const
214+ {
215+ const Locker* lock = this;
216+ MapLocker locker(const_cast<Locker*>(lock));
217+ if (!locker.IsLocked())
218+ return false;
219+ return fMap.ContainsKey(key);
220+ }
221+
222+ int32 Size() const
223+ {
224+ const Locker* lock = this;
225+ MapLocker locker(const_cast<Locker*>(lock));
226+ return fMap.Size();
227+ }
228+
229+ Iterator GetIterator()
230+ {
231+ return fMap.GetIterator();
232+ }
233+
234+ // for debugging only
235+ const HashMap<Key, Value>& GetUnsynchronizedMap() const { return fMap; }
236+ HashMap<Key, Value>& GetUnsynchronizedMap() { return fMap; }
237+
238+protected:
239+ typedef AutoLocker<Locker> MapLocker;
240+
241+ HashMap<Key, Value> fMap;
242+};
243+
244+// HashKey32
245+template<typename Value>
246+struct HashKey32 {
247+ HashKey32() {}
248+ HashKey32(const Value& value) : value(value) {}
249+
250+ uint32 GetHashCode() const
251+ {
252+ return (uint32)value;
253+ }
254+
255+ HashKey32<Value> operator=(const HashKey32<Value>& other)
256+ {
257+ value = other.value;
258+ return *this;
259+ }
260+
261+ bool operator==(const HashKey32<Value>& other) const
262+ {
263+ return (value == other.value);
264+ }
265+
266+ bool operator!=(const HashKey32<Value>& other) const
267+ {
268+ return (value != other.value);
269+ }
270+
271+ Value value;
272+};
273+
274+
275+// HashKey64
276+template<typename Value>
277+struct HashKey64 {
278+ HashKey64() {}
279+ HashKey64(const Value& value) : value(value) {}
280+
281+ uint32 GetHashCode() const
282+ {
283+ uint64 v = (uint64)value;
284+ return (uint32)(v >> 32) ^ (uint32)v;
285+ }
286+
287+ HashKey64<Value> operator=(const HashKey64<Value>& other)
288+ {
289+ value = other.value;
290+ return *this;
291+ }
292+
293+ bool operator==(const HashKey64<Value>& other) const
294+ {
295+ return (value == other.value);
296+ }
297+
298+ bool operator!=(const HashKey64<Value>& other) const
299+ {
300+ return (value != other.value);
301+ }
302+
303+ Value value;
304+};
305+
306+
307+// HashKeyPointer
308+template<typename Value>
309+struct HashKeyPointer {
310+ HashKeyPointer() {}
311+ HashKeyPointer(const Value& value) : value(value) {}
312+
313+ uint32 GetHashCode() const
314+ {
315+#if __HAIKU_ARCH_BITS == 32
316+ return (uint32)(addr_t)value;
317+#elif __HAIKU_ARCH_BITS == 64
318+ uint64 v = (uint64)(addr_t)value;
319+ return (uint32)(v >> 32) ^ (uint32)v;
320+#else
321+ #error unknown bitness
322+#endif
323+ }
324+
325+ HashKeyPointer<Value> operator=(const HashKeyPointer<Value>& other)
326+ {
327+ value = other.value;
328+ return *this;
329+ }
330+
331+ bool operator==(const HashKeyPointer<Value>& other) const
332+ {
333+ return (value == other.value);
334+ }
335+
336+ bool operator!=(const HashKeyPointer<Value>& other) const
337+ {
338+ return (value != other.value);
339+ }
340+
341+ Value value;
342+};
343+
344+
345+// HashMap
346+
347+// constructor
348+template<typename Key, typename Value>
349+HashMap<Key, Value>::HashMap()
350+ :
351+ fTable()
352+{
353+ fTable.Init();
354+}
355+
356+
357+// destructor
358+template<typename Key, typename Value>
359+HashMap<Key, Value>::~HashMap()
360+{
361+ Clear();
362+}
363+
364+
365+// InitCheck
366+template<typename Key, typename Value>
367+status_t
368+HashMap<Key, Value>::InitCheck() const
369+{
370+ return (fTable.TableSize() > 0 ? B_OK : B_NO_MEMORY);
371+}
372+
373+
374+// Put
375+template<typename Key, typename Value>
376+status_t
377+HashMap<Key, Value>::Put(const Key& key, const Value& value)
378+{
379+ Element* element = fTable.Lookup(key);
380+ if (element) {
381+ // already contains the key: just set the new value
382+ element->fValue = value;
383+ return B_OK;
384+ }
385+
386+ // does not contain the key yet: create an element and add it
387+ element = new(std::nothrow) Element(key, value);
388+ if (!element)
389+ return B_NO_MEMORY;
390+
391+ status_t error = fTable.Insert(element);
392+ if (error != B_OK)
393+ delete element;
394+
395+ return error;
396+}
397+
398+
399+// Remove
400+template<typename Key, typename Value>
401+Value
402+HashMap<Key, Value>::Remove(const Key& key)
403+{
404+ Element* element = fTable.Lookup(key);
405+ if (element == NULL)
406+ return Value();
407+
408+ fTable.Remove(element);
409+ Value value = element->fValue;
410+ delete element;
411+
412+ return value;
413+}
414+
415+
416+// Remove
417+template<typename Key, typename Value>
418+Value
419+HashMap<Key, Value>::Remove(Iterator& it)
420+{
421+ Element* element = it.fElement;
422+ if (element == NULL)
423+ return Value();
424+
425+ Value value = element->fValue;
426+
427+ fTable.RemoveUnchecked(element);
428+ delete element;
429+ it.fElement = NULL;
430+
431+ return value;
432+}
433+
434+
435+// Clear
436+template<typename Key, typename Value>
437+void
438+HashMap<Key, Value>::Clear()
439+{
440+ // clear the table and delete the elements
441+ Element* element = fTable.Clear(true);
442+ while (element != NULL) {
443+ Element* next = element->fNext;
444+ delete element;
445+ element = next;
446+ }
447+}
448+
449+
450+// Get
451+template<typename Key, typename Value>
452+Value
453+HashMap<Key, Value>::Get(const Key& key) const
454+{
455+ if (Element* element = fTable.Lookup(key))
456+ return element->fValue;
457+ return Value();
458+}
459+
460+
461+// Get
462+template<typename Key, typename Value>
463+bool
464+HashMap<Key, Value>::Get(const Key& key, Value*& _value) const
465+{
466+ if (Element* element = fTable.Lookup(key)) {
467+ _value = &element->fValue;
468+ return true;
469+ }
470+ return false;
471+}
472+
473+
474+// ContainsKey
475+template<typename Key, typename Value>
476+bool
477+HashMap<Key, Value>::ContainsKey(const Key& key) const
478+{
479+ return fTable.Lookup(key) != NULL;
480+}
481+
482+
483+// Size
484+template<typename Key, typename Value>
485+int32
486+HashMap<Key, Value>::Size() const
487+{
488+ return fTable.CountElements();
489+}
490+
491+
492+// GetIterator
493+template<typename Key, typename Value>
494+typename HashMap<Key, Value>::Iterator
495+HashMap<Key, Value>::GetIterator() const
496+{
497+ return Iterator(this);
498+}
499+
500+} // namespace BPrivate
501+
502+using BPrivate::HashMap;
503+using BPrivate::HashKey32;
504+using BPrivate::HashKey64;
505+using BPrivate::HashKeyPointer;
506+using BPrivate::SynchronizedHashMap;
507+
508+#endif // HASH_MAP_H
+95,
-0
1@@ -0,0 +1,95 @@
2+/*
3+ * Copyright 2001-2006, Haiku, Inc. All Rights Reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Frans van Nispen
8+ * Stephan Aßmus <superstippi@gmx.de>
9+ */
10+
11+#ifndef INT_POINT_H
12+#define INT_POINT_H
13+
14+#include <Point.h>
15+
16+class IntRect;
17+
18+class IntPoint {
19+ public:
20+ int32 x;
21+ int32 y;
22+
23+ IntPoint();
24+ IntPoint(int32 X, int32 Y);
25+ IntPoint(const IntPoint& p);
26+ IntPoint(const BPoint& p);
27+
28+ IntPoint& operator=(const IntPoint& p);
29+ void Set(int32 x, int32 y);
30+
31+ void ConstrainTo(const IntRect& r);
32+ void PrintToStream() const;
33+
34+ IntPoint operator+(const IntPoint& p) const;
35+ IntPoint operator-(const IntPoint& p) const;
36+ IntPoint& operator+=(const IntPoint& p);
37+ IntPoint& operator-=(const IntPoint& p);
38+
39+ bool operator!=(const IntPoint& p) const;
40+ bool operator==(const IntPoint& p) const;
41+
42+ // conversion to BPoint
43+ operator BPoint() const
44+ { return BPoint((float)x, (float)y); }
45+};
46+
47+
48+inline
49+IntPoint::IntPoint()
50+ : x(0),
51+ y(0)
52+{
53+}
54+
55+
56+inline
57+IntPoint::IntPoint(int32 x, int32 y)
58+ : x(x),
59+ y(y)
60+{
61+}
62+
63+
64+inline
65+IntPoint::IntPoint(const IntPoint& p)
66+ : x(p.x),
67+ y(p.y)
68+{
69+}
70+
71+
72+inline
73+IntPoint::IntPoint(const BPoint& p)
74+ : x((int32)p.x),
75+ y((int32)p.y)
76+{
77+}
78+
79+
80+inline IntPoint&
81+IntPoint::operator=(const IntPoint& from)
82+{
83+ x = from.x;
84+ y = from.y;
85+ return *this;
86+}
87+
88+
89+inline void
90+IntPoint::Set(int32 x, int32 y)
91+{
92+ this->x = x;
93+ this->y = y;
94+}
95+
96+#endif // INT_POINT_H
+239,
-0
1@@ -0,0 +1,239 @@
2+/*
3+ * Copyright 2001-2006, Haiku, Inc. All Rights Reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Frans van Nispen
8+ * Stephan Aßmus <superstippi@gmx.de>
9+ */
10+
11+#ifndef INT_RECT_H
12+#define INT_RECT_H
13+
14+
15+#include <Region.h>
16+
17+#include "IntPoint.h"
18+
19+class IntRect {
20+ public:
21+ int32 left;
22+ int32 top;
23+ int32 right;
24+ int32 bottom;
25+
26+ IntRect();
27+ IntRect(const IntRect& r);
28+ IntRect(const BRect& r);
29+ IntRect(int32 l, int32 t, int32 r, int32 b);
30+ IntRect(const IntPoint& lt,
31+ const IntPoint& rb);
32+
33+ IntRect& operator=(const IntRect &r);
34+ void Set(int32 l, int32 t, int32 r, int32 b);
35+
36+ void PrintToStream() const;
37+
38+ IntPoint LeftTop() const;
39+ IntPoint RightBottom() const;
40+ IntPoint LeftBottom() const;
41+ IntPoint RightTop() const;
42+
43+ void SetLeftTop(const IntPoint& p);
44+ void SetRightBottom(const IntPoint& p);
45+ void SetLeftBottom(const IntPoint& p);
46+ void SetRightTop(const IntPoint& p);
47+
48+ // transformation
49+ void InsetBy(const IntPoint& p);
50+ void InsetBy(int32 dx, int32 dy);
51+ void OffsetBy(const IntPoint& p);
52+ void OffsetBy(int32 dx, int32 dy);
53+ void OffsetTo(const IntPoint& p);
54+ void OffsetTo(int32 x, int32 y);
55+
56+ // expression transformations
57+ IntRect& InsetBySelf(const IntPoint& p);
58+ IntRect& InsetBySelf(int32 dx, int32 dy);
59+ IntRect InsetByCopy(const IntPoint& p);
60+ IntRect InsetByCopy(int32 dx, int32 dy);
61+ IntRect& OffsetBySelf(const IntPoint& p);
62+ IntRect& OffsetBySelf(int32 dx, int32 dy);
63+ IntRect OffsetByCopy(const IntPoint& p);
64+ IntRect OffsetByCopy(int32 dx, int32 dy);
65+ IntRect& OffsetToSelf(const IntPoint& p);
66+ IntRect& OffsetToSelf(int32 dx, int32 dy);
67+ IntRect OffsetToCopy(const IntPoint& p);
68+ IntRect OffsetToCopy(int32 dx, int32 dy);
69+
70+ // comparison
71+ bool operator==(const IntRect& r) const;
72+ bool operator!=(const IntRect& r) const;
73+
74+ // intersection and union
75+ IntRect operator&(const IntRect& r) const;
76+ IntRect operator|(const IntRect& r) const;
77+
78+ // conversion to BRect and clipping_rect
79+ operator clipping_rect() const;
80+ operator BRect() const
81+ { return BRect(left, top,
82+ right, bottom); }
83+
84+ bool Intersects(const IntRect& r) const;
85+ bool IsValid() const;
86+ int32 Width() const;
87+ int32 IntegerWidth() const;
88+ int32 Height() const;
89+ int32 IntegerHeight() const;
90+ bool Contains(const IntPoint& p) const;
91+ bool Contains(const IntRect& r) const;
92+};
93+
94+
95+// inline definitions ----------------------------------------------------------
96+
97+inline IntPoint
98+IntRect::LeftTop() const
99+{
100+ return *(const IntPoint*)&left;
101+}
102+
103+
104+inline IntPoint
105+IntRect::RightBottom() const
106+{
107+ return *(const IntPoint*)&right;
108+}
109+
110+
111+inline IntPoint
112+IntRect::LeftBottom() const
113+{
114+ return IntPoint(left, bottom);
115+}
116+
117+
118+inline IntPoint
119+IntRect::RightTop() const
120+{
121+ return IntPoint(right, top);
122+}
123+
124+
125+inline
126+IntRect::IntRect()
127+{
128+ top = left = 0;
129+ bottom = right = -1;
130+}
131+
132+
133+inline
134+IntRect::IntRect(int32 l, int32 t, int32 r, int32 b)
135+{
136+ left = l;
137+ top = t;
138+ right = r;
139+ bottom = b;
140+}
141+
142+
143+inline
144+IntRect::IntRect(const IntRect &r)
145+{
146+ left = r.left;
147+ top = r.top;
148+ right = r.right;
149+ bottom = r.bottom;
150+}
151+
152+
153+inline
154+IntRect::IntRect(const BRect &r)
155+{
156+ left = (int32)r.left;
157+ top = (int32)r.top;
158+ right = (int32)r.right;
159+ bottom = (int32)r.bottom;
160+}
161+
162+
163+inline
164+IntRect::IntRect(const IntPoint& leftTop, const IntPoint& rightBottom)
165+{
166+ left = leftTop.x;
167+ top = leftTop.y;
168+ right = rightBottom.x;
169+ bottom = rightBottom.y;
170+}
171+
172+
173+inline IntRect &
174+IntRect::operator=(const IntRect& from)
175+{
176+ left = from.left;
177+ top = from.top;
178+ right = from.right;
179+ bottom = from.bottom;
180+ return *this;
181+}
182+
183+
184+inline void
185+IntRect::Set(int32 l, int32 t, int32 r, int32 b)
186+{
187+ left = l;
188+ top = t;
189+ right = r;
190+ bottom = b;
191+}
192+
193+
194+inline bool
195+IntRect::IsValid() const
196+{
197+ return left <= right && top <= bottom;
198+}
199+
200+
201+inline int32
202+IntRect::IntegerWidth() const
203+{
204+ return right - left;
205+}
206+
207+
208+inline int32
209+IntRect::Width() const
210+{
211+ return right - left;
212+}
213+
214+
215+inline int32
216+IntRect::IntegerHeight() const
217+{
218+ return bottom - top;
219+}
220+
221+
222+inline int32
223+IntRect::Height() const
224+{
225+ return bottom - top;
226+}
227+
228+inline
229+IntRect::operator clipping_rect() const
230+{
231+ clipping_rect r;
232+ r.left = left;
233+ r.top = top;
234+ r.right = right;
235+ r.bottom = bottom;
236+ return r;
237+}
238+
239+
240+#endif // INT_RECT_H
1@@ -0,0 +1,67 @@
2+/*
3+ * Copyright 2001-2006, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Pahtz <pahtz@yahoo.com.au>
9+ * Axel Dörfler, axeld@pinc-software.de
10+ */
11+#ifndef _LINK_RECEIVER_H
12+#define _LINK_RECEIVER_H
13+
14+
15+#include <OS.h>
16+
17+
18+class BGradient;
19+class BString;
20+class BRegion;
21+
22+
23+namespace BPrivate {
24+
25+class LinkReceiver {
26+ public:
27+ LinkReceiver(port_id port);
28+ virtual ~LinkReceiver(void);
29+
30+ void SetPort(port_id port);
31+ port_id Port(void) const { return fReceivePort; }
32+
33+ status_t GetNextMessage(int32& code, bigtime_t timeout = B_INFINITE_TIMEOUT);
34+ bool HasMessages() const;
35+ bool NeedsReply() const;
36+ int32 Code() const;
37+
38+ virtual status_t Read(void* data, ssize_t size);
39+ status_t ReadString(char** _string, size_t* _length = NULL);
40+ status_t ReadString(BString& string, size_t* _length = NULL);
41+ status_t ReadString(char* buffer, size_t bufferSize);
42+ status_t ReadRegion(BRegion* region);
43+ status_t ReadGradient(BGradient** gradient);
44+
45+ template <class Type> status_t Read(Type *data)
46+ { return Read(data, sizeof(Type)); }
47+
48+ protected:
49+ virtual status_t ReadFromPort(bigtime_t timeout);
50+ virtual status_t AdjustReplyBuffer(bigtime_t timeout);
51+ void ResetBuffer();
52+
53+ port_id fReceivePort;
54+
55+ char* fRecvBuffer;
56+ int32 fRecvPosition; //current read position
57+ int32 fRecvStart; //start of current message
58+ int32 fRecvBufferSize;
59+
60+ int32 fDataSize; //size of data in recv buffer
61+ int32 fReplySize; //size of current reply message
62+
63+ status_t fReadError; //Read failed for current message
64+};
65+
66+} // namespace BPrivate
67+
68+#endif // _LINK_RECEIVER_H
+78,
-0
1@@ -0,0 +1,78 @@
2+/*
3+ * Copyright 2001-2005, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Pahtz <pahtz@yahoo.com.au>
9+ * Axel Dörfler, axeld@pinc-software.de
10+ */
11+#ifndef _LINK_SENDER_H
12+#define _LINK_SENDER_H
13+
14+
15+#include <OS.h>
16+
17+
18+namespace BPrivate {
19+
20+class LinkSender {
21+ public:
22+ LinkSender(port_id sendport);
23+ virtual ~LinkSender(void);
24+
25+ void SetPort(port_id port);
26+ port_id Port() const { return fPort; }
27+
28+ team_id TargetTeam() const;
29+ void SetTargetTeam(team_id team);
30+
31+ status_t StartMessage(int32 code, size_t minSize = 0);
32+ void CancelMessage(void);
33+ status_t EndMessage(bool needsReply = false);
34+
35+ status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT, bool needsReply = false);
36+
37+ status_t Attach(const void *data, size_t size);
38+ status_t AttachString(const char *string, int32 maxLength = -1);
39+ template <class Type> status_t Attach(const Type& data)
40+ {
41+ return Attach(&data, sizeof(Type));
42+ }
43+
44+ protected:
45+ size_t SpaceLeft() const { return fBufferSize - fCurrentEnd; }
46+ size_t CurrentMessageSize() const { return fCurrentEnd - fCurrentStart; }
47+
48+ status_t AdjustBuffer(size_t newBufferSize, char **_oldBuffer = NULL);
49+ status_t FlushCompleted(size_t newBufferSize);
50+
51+ port_id fPort;
52+ team_id fTargetTeam;
53+
54+ char *fBuffer;
55+ size_t fBufferSize;
56+
57+ uint32 fCurrentEnd; // current append position
58+ uint32 fCurrentStart; // start of current message
59+
60+ status_t fCurrentStatus;
61+};
62+
63+
64+inline team_id
65+LinkSender::TargetTeam() const
66+{
67+ return fTargetTeam;
68+}
69+
70+
71+inline void
72+LinkSender::SetTargetTeam(team_id team)
73+{
74+ fTargetTeam = team;
75+}
76+
77+} // namespace BPrivate
78+
79+#endif /* _LINK_SENDER_H */
1@@ -0,0 +1,87 @@
2+/*
3+ * Copyright 2010-2011, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Stephan Aßmus <superstippi@gmx.de>
8+ * Ingo Weinhold <ingo_weinhold@gmx.de>
9+ * Clemens Zeidler <haiku@clemens-zeidler.de>
10+ */
11+
12+
13+#include "MagneticBorder.h"
14+
15+#include "Decorator.h"
16+#include "Window.h"
17+#include "Screen.h"
18+
19+
20+MagneticBorder::MagneticBorder()
21+ :
22+ fLastSnapTime(0)
23+{
24+
25+}
26+
27+
28+bool
29+MagneticBorder::AlterDeltaForSnap(Window* window, BPoint& delta, bigtime_t now)
30+{
31+ BRect frame = window->Frame();
32+ Decorator* decorator = window->Decorator();
33+ if (decorator)
34+ frame = decorator->GetFootprint().Frame();
35+
36+ return AlterDeltaForSnap(window->Screen(), frame, delta, now);
37+}
38+
39+
40+bool
41+MagneticBorder::AlterDeltaForSnap(const Screen* screen, BRect& frame,
42+ BPoint& delta, bigtime_t now)
43+{
44+ // Alter the delta (which is a proposed offset used while dragging a
45+ // window) so that the frame of the window 'snaps' to the edges of the
46+ // screen.
47+
48+ const bigtime_t kSnappingDuration = 1500000LL;
49+ const bigtime_t kSnappingPause = 3000000LL;
50+ const float kSnapDistance = 8.0f;
51+
52+ if (now - fLastSnapTime > kSnappingDuration
53+ && now - fLastSnapTime < kSnappingPause) {
54+ // Maintain a pause between snapping.
55+ return false;
56+ }
57+
58+ // TODO: Perhaps obtain the usable area (not covered by the Deskbar)?
59+ BRect screenFrame = screen->Frame();
60+ BRect originalFrame = frame;
61+ frame.OffsetBy(delta);
62+
63+ float leftDist = fabs(frame.left - screenFrame.left);
64+ float topDist = fabs(frame.top - screenFrame.top);
65+ float rightDist = fabs(frame.right - screenFrame.right);
66+ float bottomDist = fabs(frame.bottom - screenFrame.bottom);
67+
68+ bool snapped = false;
69+ if (leftDist < kSnapDistance || rightDist < kSnapDistance) {
70+ snapped = true;
71+ if (leftDist < rightDist)
72+ delta.x = screenFrame.left - originalFrame.left;
73+ else
74+ delta.x = screenFrame.right - originalFrame.right;
75+ }
76+
77+ if (topDist < kSnapDistance || bottomDist < kSnapDistance) {
78+ snapped = true;
79+ if (topDist < bottomDist)
80+ delta.y = screenFrame.top - originalFrame.top;
81+ else
82+ delta.y = screenFrame.bottom - originalFrame.bottom;
83+ }
84+ if (snapped && now - fLastSnapTime > kSnappingPause)
85+ fLastSnapTime = now;
86+
87+ return snapped;
88+}
1@@ -0,0 +1,34 @@
2+/*
3+ * Copyright 2011, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Clemens Zeidler <haiku@clemens-zeidler.de>
8+ */
9+#ifndef MAGNETIC_BORDRER_H
10+#define MAGNETIC_BORDRER_H
11+
12+
13+#include <Point.h>
14+#include <Screen.h>
15+
16+
17+class Screen;
18+class Window;
19+
20+
21+class MagneticBorder {
22+public:
23+ MagneticBorder();
24+
25+ bool AlterDeltaForSnap(Window* window, BPoint& delta,
26+ bigtime_t now);
27+ bool AlterDeltaForSnap(const Screen* screen,
28+ BRect& frame, BPoint& delta, bigtime_t now);
29+
30+private:
31+ bigtime_t fLastSnapTime;
32+};
33+
34+
35+#endif // MAGNETIC_BORDRER_H
1@@ -0,0 +1,60 @@
2+/*
3+ * Copyright 2005-2016, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef MESSAGE_LOOPER_H
10+#define MESSAGE_LOOPER_H
11+
12+
13+#include <PortLink.h>
14+#include <Locker.h>
15+#include <OS.h>
16+
17+
18+class MessageLooper : public BLocker {
19+public:
20+ MessageLooper(const char* name);
21+ virtual ~MessageLooper();
22+
23+ virtual status_t Run();
24+ virtual void Quit();
25+
26+ status_t PostMessage(int32 code,
27+ bigtime_t timeout = B_INFINITE_TIMEOUT);
28+
29+ thread_id Thread() const { return fThread; }
30+ bool IsQuitting() const { return fQuitting; }
31+ sem_id DeathSemaphore() const
32+ { return fDeathSemaphore; }
33+
34+ virtual port_id MessagePort() const = 0;
35+
36+ static status_t WaitForQuit(sem_id semaphore,
37+ bigtime_t timeout = B_INFINITE_TIMEOUT);
38+
39+private:
40+ virtual void _PrepareQuit();
41+ virtual void _GetLooperName(char* name, size_t length);
42+ virtual void _DispatchMessage(int32 code,
43+ BPrivate::LinkReceiver& link);
44+ virtual void _MessageLooper();
45+
46+protected:
47+ static int32 _message_thread(void*_looper);
48+
49+protected:
50+ const char* fName;
51+ thread_id fThread;
52+ BPrivate::PortLink fLink;
53+ bool fQuitting;
54+ sem_id fDeathSemaphore;
55+};
56+
57+
58+static const int32 kMsgQuitLooper = 'quit';
59+
60+
61+#endif /* MESSAGE_LOOPER_H */
+181,
-0
1@@ -0,0 +1,181 @@
2+/*
3+ * Copyright 2005-2009, Haiku, Inc. All Rights Reserved.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Copyright 1999, Be Incorporated. All Rights Reserved.
7+ * This file may be used under the terms of the Be Sample Code License.
8+ */
9+#ifndef MULTI_LOCKER_H
10+#define MULTI_LOCKER_H
11+
12+
13+/*! multiple-reader single-writer locking class
14+
15+ IMPORTANT:
16+ * nested read locks are not supported
17+ * a reader becoming the write is not supported
18+ * nested write locks are supported
19+ * a writer can do read locks, even nested ones
20+ * in case of problems, #define DEBUG 1 in the .cpp
21+*/
22+
23+
24+#include <OS.h>
25+#include <locks.h>
26+
27+
28+#define MULTI_LOCKER_TIMING 0
29+#if DEBUG
30+# include <assert.h>
31+# define MULTI_LOCKER_DEBUG DEBUG
32+#endif
33+
34+#if MULTI_LOCKER_DEBUG
35+# define ASSERT_MULTI_LOCKED(x) assert((x).IsWriteLocked() || (x).IsReadLocked())
36+# define ASSERT_MULTI_READ_LOCKED(x) assert((x).IsReadLocked())
37+# define ASSERT_MULTI_WRITE_LOCKED(x) assert((x).IsWriteLocked())
38+#else
39+# define MULTI_LOCKER_DEBUG 0
40+# define ASSERT_MULTI_LOCKED(x) ;
41+# define ASSERT_MULTI_READ_LOCKED(x) ;
42+# define ASSERT_MULTI_WRITE_LOCKED(x) ;
43+#endif
44+
45+
46+class MultiLocker {
47+public:
48+ MultiLocker(const char* baseName);
49+ virtual ~MultiLocker();
50+
51+ status_t InitCheck();
52+
53+ // locking for reading or writing
54+ bool ReadLock();
55+ bool WriteLock();
56+
57+ // unlocking after reading or writing
58+ bool ReadUnlock();
59+ bool WriteUnlock();
60+
61+ // does the current thread hold a write lock?
62+ bool IsWriteLocked() const;
63+
64+#if MULTI_LOCKER_DEBUG
65+ // in DEBUG mode returns whether the lock is held
66+ // in non-debug mode returns true
67+ bool IsReadLocked() const;
68+#endif
69+
70+private:
71+ MultiLocker();
72+ MultiLocker(const MultiLocker& other);
73+ MultiLocker& operator=(const MultiLocker& other);
74+ // not implemented
75+
76+#if !MULTI_LOCKER_DEBUG
77+ rw_lock fLock;
78+#else
79+ // functions for managing the DEBUG reader array
80+ void _RegisterThread();
81+ void _UnregisterThread();
82+
83+ sem_id fLock;
84+ int32* fDebugArray;
85+ int32 fMaxThreads;
86+ int32 fWriterNest;
87+ thread_id fWriterThread;
88+#endif // MULTI_LOCKER_DEBUG
89+
90+ status_t fInit;
91+
92+#if MULTI_LOCKER_TIMING
93+ uint32 rl_count;
94+ bigtime_t rl_time;
95+ uint32 ru_count;
96+ bigtime_t ru_time;
97+ uint32 wl_count;
98+ bigtime_t wl_time;
99+ uint32 wu_count;
100+ bigtime_t wu_time;
101+ uint32 islock_count;
102+ bigtime_t islock_time;
103+#endif
104+};
105+
106+
107+class AutoWriteLocker {
108+public:
109+ AutoWriteLocker(MultiLocker* lock)
110+ :
111+ fLock(*lock)
112+ {
113+ fLocked = fLock.WriteLock();
114+ }
115+
116+ AutoWriteLocker(MultiLocker& lock)
117+ :
118+ fLock(lock)
119+ {
120+ fLocked = fLock.WriteLock();
121+ }
122+
123+ ~AutoWriteLocker()
124+ {
125+ if (fLocked)
126+ fLock.WriteUnlock();
127+ }
128+
129+ bool IsLocked() const
130+ {
131+ return fLock.IsWriteLocked();
132+ }
133+
134+ void Unlock()
135+ {
136+ if (fLocked) {
137+ fLock.WriteUnlock();
138+ fLocked = false;
139+ }
140+ }
141+
142+private:
143+ MultiLocker& fLock;
144+ bool fLocked;
145+};
146+
147+
148+class AutoReadLocker {
149+public:
150+ AutoReadLocker(MultiLocker* lock)
151+ :
152+ fLock(*lock)
153+ {
154+ fLocked = fLock.ReadLock();
155+ }
156+
157+ AutoReadLocker(MultiLocker& lock)
158+ :
159+ fLock(lock)
160+ {
161+ fLocked = fLock.ReadLock();
162+ }
163+
164+ ~AutoReadLocker()
165+ {
166+ Unlock();
167+ }
168+
169+ void Unlock()
170+ {
171+ if (fLocked) {
172+ fLock.ReadUnlock();
173+ fLocked = false;
174+ }
175+ }
176+
177+private:
178+ MultiLocker& fLock;
179+ bool fLocked;
180+};
181+
182+#endif // MULTI_LOCKER_H
1@@ -0,0 +1 @@
2+#include <../private/kernel/util/OpenHashTable.h>
+179,
-0
1@@ -0,0 +1,179 @@
2+/*
3+ * Copyright (c) 2001-2007, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Author: DarkWyrm <bpmagic@columbus.rr.com>
7+ * Stephan Aßmus <superstippi@gmx.de>
8+ */
9+#ifndef PATTERNHANDLER_H
10+#define PATTERNHANDLER_H
11+
12+
13+#include <stdio.h>
14+#include <string.h>
15+
16+#include <GraphicsDefs.h>
17+
18+class BPoint;
19+
20+
21+class Pattern {
22+ public:
23+
24+ Pattern() {}
25+
26+ Pattern(const uint64& p)
27+ { fPattern.type64 = p; }
28+
29+ Pattern(const int8* p)
30+ { fPattern.type64 = *((const uint64*)p); }
31+
32+ Pattern(const Pattern& src)
33+ { fPattern.type64 = src.fPattern.type64; }
34+
35+ Pattern(const pattern& src)
36+ { fPattern.type64 = *(uint64*)src.data; }
37+
38+ inline const int8* GetInt8() const
39+ { return fPattern.type8; }
40+
41+ inline uint64 GetInt64() const
42+ { return fPattern.type64; }
43+
44+ inline const ::pattern& GetPattern() const
45+ { return *(const ::pattern*)&fPattern.type64; }
46+
47+ inline void Set(const int8* p)
48+ { fPattern.type64 = *((const uint64*)p); }
49+
50+ inline void Set(const uint64& p)
51+ { fPattern.type64 = p; }
52+
53+ Pattern& operator=(const Pattern& from)
54+ { fPattern.type64 = from.fPattern.type64; return *this; }
55+
56+ Pattern& operator=(const int64 &from)
57+ { fPattern.type64 = from; return *this; }
58+
59+ Pattern& operator=(const pattern &from)
60+ { memcpy(&fPattern.type64, &from, sizeof(pattern)); return *this; }
61+
62+ bool operator==(const Pattern& other) const
63+ { return fPattern.type64 == other.fPattern.type64; }
64+
65+ bool operator==(const pattern& other) const
66+ { return fPattern.type64 == *(uint64*)other.data; }
67+
68+ private:
69+
70+ typedef union
71+ {
72+ uint64 type64;
73+ int8 type8[8];
74+ } pattern_union;
75+
76+ pattern_union fPattern;
77+};
78+
79+extern const Pattern kSolidHigh;
80+extern const Pattern kSolidLow;
81+extern const Pattern kMixedColors;
82+
83+/*!
84+ \brief Class for easy calculation and use of patterns
85+
86+ PatternHandlers are designed specifically for DisplayDriver subclasses.
87+ Pattern support can be easily added by setting the pattern to use via
88+ SetTarget, and then merely retrieving the value for the coordinates
89+ specified.
90+*/
91+class PatternHandler {
92+ public:
93+ PatternHandler(void);
94+ PatternHandler(const int8* p);
95+ PatternHandler(const uint64& p);
96+ PatternHandler(const Pattern& p);
97+ PatternHandler(const PatternHandler& other);
98+ virtual ~PatternHandler(void);
99+
100+ void SetPattern(const int8* p);
101+ void SetPattern(const uint64& p);
102+ void SetPattern(const Pattern& p);
103+ void SetPattern(const pattern& p);
104+
105+ void SetColors(const rgb_color& high,
106+ const rgb_color& low);
107+ void SetHighColor(const rgb_color& color);
108+ void SetLowColor(const rgb_color& color);
109+
110+ rgb_color HighColor() const
111+ { return fHighColor; }
112+ rgb_color LowColor() const
113+ { return fLowColor; }
114+
115+ rgb_color ColorAt(const BPoint& pt) const;
116+ rgb_color ColorAt(float x, float y) const;
117+ inline rgb_color ColorAt(int x, int y) const;
118+
119+ bool IsHighColor(const BPoint& pt) const;
120+ inline bool IsHighColor(int x, int y) const;
121+ inline bool IsSolidHigh() const
122+ { return fPattern == B_SOLID_HIGH; }
123+ inline bool IsSolidLow() const
124+ { return fPattern == B_SOLID_LOW; }
125+ inline bool IsSolid() const
126+ { return IsSolidHigh() || IsSolidLow(); }
127+
128+ const pattern* GetR5Pattern(void) const
129+ { return (const pattern*)fPattern.GetInt8(); }
130+ const Pattern& GetPattern(void) const
131+ { return fPattern; }
132+
133+ void SetOffsets(int32 x, int32 y);
134+
135+ void MakeOpCopyColorCache();
136+ inline const rgb_color* OpCopyColorCache() const
137+ { return fOpCopyColorCache; }
138+
139+ private:
140+ Pattern fPattern;
141+ rgb_color fHighColor;
142+ rgb_color fLowColor;
143+
144+ uint16 fXOffset;
145+ uint16 fYOffset;
146+
147+ rgb_color fOpCopyColorCache[256];
148+ uint64 fColorsWhenCached;
149+};
150+
151+/*!
152+ \brief Obtains the color in the pattern at the specified coordinates
153+ \param x X coordinate to get the color for
154+ \param y Y coordinate to get the color for
155+ \return Color for the coordinates
156+*/
157+inline rgb_color
158+PatternHandler::ColorAt(int x, int y) const
159+{
160+ return IsHighColor(x, y) ? fHighColor : fLowColor;
161+}
162+
163+/*!
164+ \brief Obtains the value of the pattern at the specified coordinates
165+ \param pt Coordinates to get the value for
166+ \return Value for the coordinates - true if high, false if low.
167+*/
168+
169+inline bool
170+PatternHandler::IsHighColor(int x, int y) const
171+{
172+ x -= fXOffset;
173+ y -= fYOffset;
174+ const int8* ptr = fPattern.GetInt8();
175+ int32 value = ptr[y & 7] & (1 << (7 - (x & 7)) );
176+
177+ return value != 0;
178+}
179+
180+#endif
+28,
-0
1@@ -0,0 +1,28 @@
2+/*
3+ * Copyright 2005-2010, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef _PORT_LINK_H
10+#define _PORT_LINK_H
11+
12+
13+#include <ServerLink.h>
14+
15+
16+namespace BPrivate {
17+
18+
19+class PortLink : public ServerLink {
20+public:
21+ PortLink(port_id sender = -1,
22+ port_id receiver = -1);
23+ virtual ~PortLink();
24+};
25+
26+
27+} // namespace BPrivate
28+
29+#endif /* _PORT_LINK_H */
+77,
-0
1@@ -0,0 +1,77 @@
2+/*
3+ * Copyright 2001-2006, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ */
9+#ifndef RGB_COLOR_H
10+#define RGB_COLOR_H
11+
12+
13+#include <GraphicsDefs.h>
14+
15+
16+class RGBColor {
17+ public:
18+ RGBColor(uint8 r,
19+ uint8 g,
20+ uint8 b,
21+ uint8 a = 255);
22+ RGBColor(int r,
23+ int g,
24+ int b,
25+ int a = 255);
26+ RGBColor(const rgb_color& color);
27+ RGBColor(uint16 color);
28+ RGBColor(uint8 color);
29+ RGBColor(const RGBColor& color);
30+ RGBColor();
31+
32+ uint8 GetColor8() const;
33+ uint16 GetColor15() const;
34+ uint16 GetColor16() const;
35+ rgb_color GetColor32() const;
36+
37+ void SetColor(uint8 r,
38+ uint8 g,
39+ uint8 b,
40+ uint8 a = 255);
41+ void SetColor(int r,
42+ int g,
43+ int b,
44+ int a = 255);
45+ void SetColor(uint16 color16);
46+ void SetColor(uint8 color8);
47+ void SetColor(const rgb_color& color);
48+ void SetColor(const RGBColor& color);
49+
50+ const RGBColor& operator=(const RGBColor& color);
51+ const RGBColor& operator=(const rgb_color& color);
52+
53+ bool operator==(const rgb_color& color) const;
54+ bool operator==(const RGBColor& color) const;
55+ bool operator!=(const rgb_color& color) const;
56+ bool operator!=(const RGBColor& color) const;
57+
58+ // conversion to rgb_color
59+ operator rgb_color() const
60+ { return fColor32; }
61+
62+ bool IsTransparentMagic() const;
63+
64+ void PrintToStream() const;
65+
66+ protected:
67+ rgb_color fColor32;
68+
69+ // caching
70+ mutable uint16 fColor16;
71+ mutable uint16 fColor15;
72+ mutable uint8 fColor8;
73+ mutable bool fUpdate8;
74+ mutable bool fUpdate15;
75+ mutable bool fUpdate16;
76+};
77+
78+#endif // RGB_COLOR_H
1@@ -0,0 +1,55 @@
2+/*
3+ * Copyright 2001-2005, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Axel Dörfler, axeld@pinc-software.de
9+ */
10+#ifndef REFERENCE_COUNTING_H
11+#define REFERENCE_COUNTING_H
12+
13+
14+#include <SupportDefs.h>
15+
16+
17+/*!
18+ \class ReferenceCounting ReferenceCounting.h
19+ \brief Base class for reference counting objects
20+
21+ ReferenceCounting objects track dependencies upon a particular object. In this way,
22+ it is possible to ensure that a shared resource is not deleted if something else
23+ needs it. How the dependency tracking is done largely depends on the child class.
24+*/
25+class ReferenceCounting {
26+ public:
27+ ReferenceCounting()
28+ : fReferenceCount(1) {}
29+ virtual ~ReferenceCounting() {}
30+
31+ inline void Acquire();
32+ inline bool Release();
33+
34+ private:
35+ int32 fReferenceCount;
36+};
37+
38+
39+inline void
40+ReferenceCounting::Acquire()
41+{
42+ atomic_add(&fReferenceCount, 1);
43+}
44+
45+inline bool
46+ReferenceCounting::Release()
47+{
48+ if (atomic_add(&fReferenceCount, -1) == 1) {
49+ delete this;
50+ return true;
51+ }
52+
53+ return false;
54+}
55+
56+#endif /* REFERENCE_COUNTING_H */
1@@ -0,0 +1,59 @@
2+/*
3+ * Copyright 2010-2015, Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Clemens Zeidler <haiku@clemens-zeidler.de>
8+ */
9+#ifndef SAT_DECORATOR_H
10+#define SAT_DECORATOR_H
11+
12+
13+#include "DecorManager.h"
14+#include "DefaultDecorator.h"
15+#include "DefaultWindowBehaviour.h"
16+#include "StackAndTile.h"
17+
18+
19+class Desktop;
20+
21+
22+class SATDecorator : public DefaultDecorator {
23+public:
24+ enum {
25+ HIGHLIGHT_STACK_AND_TILE = HIGHLIGHT_USER_DEFINED
26+ };
27+
28+public:
29+ SATDecorator(DesktopSettings& settings,
30+ BRect frame, Desktop* desktop);
31+
32+protected:
33+ virtual void UpdateColors(DesktopSettings& settings);
34+ virtual void GetComponentColors(Component component,
35+ uint8 highlight, ComponentColors _colors,
36+ Decorator::Tab* tab = NULL);
37+
38+private:
39+ rgb_color fHighlightTabColor;
40+ rgb_color fHighlightTabColorLight;
41+ rgb_color fHighlightTabColorBevel;
42+ rgb_color fHighlightTabColorShadow;
43+};
44+
45+
46+class SATWindowBehaviour : public DefaultWindowBehaviour {
47+public:
48+ SATWindowBehaviour(Window* window,
49+ StackAndTile* sat);
50+
51+protected:
52+ virtual bool AlterDeltaForSnap(Window* window, BPoint& delta,
53+ bigtime_t now);
54+
55+private:
56+ StackAndTile* fStackAndTile;
57+};
58+
59+
60+#endif
1@@ -0,0 +1,56 @@
2+/*
3+ * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
4+ * This file may be used under the terms of the MIT License.
5+ */
6+#ifndef SCREEN_CONFIGURATIONS_H
7+#define SCREEN_CONFIGURATIONS_H
8+
9+
10+#include <Accelerant.h>
11+#include <Rect.h>
12+
13+#include <ObjectList.h>
14+
15+
16+class BMessage;
17+
18+
19+struct screen_configuration {
20+ int32 id;
21+ monitor_info info;
22+ BRect frame;
23+ display_mode mode;
24+ float brightness;
25+ bool has_info;
26+ bool is_current;
27+};
28+
29+
30+class ScreenConfigurations {
31+public:
32+ ScreenConfigurations();
33+ ~ScreenConfigurations();
34+
35+ screen_configuration* CurrentByID(int32 id) const;
36+ screen_configuration* BestFit(int32 id, const monitor_info* info,
37+ bool* _exactMatch = NULL) const;
38+
39+ status_t Set(int32 id, const monitor_info* info,
40+ const BRect& frame,
41+ const display_mode& mode);
42+ void SetBrightness(int32 id, float brightness);
43+ float Brightness(int32 id);
44+ void Remove(screen_configuration* configuration);
45+
46+ status_t Store(BMessage& settings) const;
47+ status_t Restore(const BMessage& settings);
48+
49+private:
50+ typedef BObjectList<screen_configuration> ConfigurationList;
51+
52+ ConfigurationList fConfigurations;
53+};
54+
55+
56+#endif // SCREEN_CONFIGURATIONS_H
57+
1@@ -0,0 +1,72 @@
2+/*
3+ * Copyright 2005, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef SCREEN_MANAGER_H
10+#define SCREEN_MANAGER_H
11+
12+
13+#include <AutoDeleter.h>
14+#include <Looper.h>
15+#include <ObjectList.h>
16+
17+
18+class BMessage;
19+
20+class DrawingEngine;
21+class HWInterface;
22+class HWInterfaceListener;
23+class Screen;
24+
25+
26+typedef BObjectList<Screen> ScreenList;
27+
28+
29+class ScreenOwner {
30+ public:
31+ virtual ~ScreenOwner() {};
32+ virtual void ScreenRemoved(Screen* screen) = 0;
33+ virtual void ScreenAdded(Screen* screen) = 0;
34+ virtual void ScreenChanged(Screen* screen) = 0;
35+
36+ virtual bool ReleaseScreen(Screen* screen) = 0;
37+};
38+
39+
40+class ScreenManager : public BLooper {
41+ public:
42+ ScreenManager();
43+ virtual ~ScreenManager();
44+
45+ Screen* ScreenAt(int32 index) const;
46+ int32 CountScreens() const;
47+
48+ status_t AcquireScreens(ScreenOwner* owner, int32* wishList,
49+ int32 wishCount, const char* target, bool force,
50+ ScreenList& list);
51+ void ReleaseScreens(ScreenList& list);
52+
53+ void ScreenChanged(Screen* screen);
54+
55+ virtual void MessageReceived(BMessage* message);
56+
57+ private:
58+ struct screen_item {
59+ ObjectDeleter<Screen> screen;
60+ ScreenOwner* owner;
61+ ObjectDeleter<HWInterfaceListener>
62+ listener;
63+ };
64+
65+ void _ScanDrivers();
66+ screen_item* _AddHWInterface(HWInterface* interface);
67+
68+ BObjectList<screen_item> fScreenList;
69+};
70+
71+extern ScreenManager *gScreenManager;
72+
73+#endif /* SCREEN_MANAGER_H */
+145,
-0
1@@ -0,0 +1,145 @@
2+/*
3+ * Copyright 2001-2010, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Axel Dörfler, axeld@pinc-software.de
9+ */
10+#ifndef SERVER_BITMAP_H
11+#define SERVER_BITMAP_H
12+
13+
14+#include <AutoDeleter.h>
15+#include <GraphicsDefs.h>
16+#include <Rect.h>
17+#include <OS.h>
18+
19+#include <Referenceable.h>
20+
21+#include "ClientMemoryAllocator.h"
22+
23+
24+class BitmapManager;
25+class HWInterface;
26+class Overlay;
27+class ServerApp;
28+
29+
30+/*! \class ServerBitmap ServerBitmap.h
31+ \brief Bitmap class used inside the server.
32+
33+ This class is not directly allocated or freed. Instead, it is
34+ managed by the BitmapManager class. It is also the base class for
35+ all cursors. Every BBitmap has a shadow ServerBitmap object.
36+*/
37+class ServerBitmap : public BReferenceable {
38+public:
39+ inline bool IsValid() const
40+ { return fBuffer != NULL; }
41+
42+ inline uint8* Bits() const
43+ { return fBuffer; }
44+ inline uint32 BitsLength() const
45+ { return (uint32)(fBytesPerRow * fHeight); }
46+
47+ inline BRect Bounds() const
48+ { return BRect(0, 0, fWidth - 1, fHeight - 1); }
49+ inline int32 Width() const
50+ { return fWidth; }
51+ inline int32 Height() const
52+ { return fHeight; }
53+
54+ inline int32 BytesPerRow() const
55+ { return fBytesPerRow; }
56+
57+ inline color_space ColorSpace() const
58+ { return fSpace; }
59+ inline uint32 Flags() const
60+ { return fFlags; }
61+
62+ //! Returns the identifier token for the bitmap
63+ inline int32 Token() const
64+ { return fToken; }
65+
66+ area_id Area() const;
67+ uint32 AreaOffset() const;
68+
69+ void SetOverlay(::Overlay* overlay);
70+ ::Overlay* Overlay() const;
71+
72+ void SetOwner(ServerApp* owner);
73+ ServerApp* Owner() const;
74+
75+ //! Does a shallow copy of the bitmap passed to it
76+ inline void ShallowCopy(const ServerBitmap *from);
77+
78+ status_t ImportBits(const void *bits, int32 bitsLength,
79+ int32 bytesPerRow, color_space colorSpace);
80+ status_t ImportBits(const void *bits, int32 bitsLength,
81+ int32 bytesPerRow, color_space colorSpace,
82+ BPoint from, BPoint to, int32 width,
83+ int32 height);
84+
85+ void PrintToStream();
86+
87+protected:
88+ friend class BitmapManager;
89+
90+ ServerBitmap(BRect rect, color_space space,
91+ uint32 flags, int32 bytesPerRow = -1,
92+ screen_id screen = B_MAIN_SCREEN_ID);
93+ ServerBitmap(const ServerBitmap* bmp);
94+ virtual ~ServerBitmap();
95+
96+ void AllocateBuffer();
97+
98+protected:
99+ ClientMemory fClientMemory;
100+ AreaMemory* fMemory;
101+ ObjectDeleter< ::Overlay>
102+ fOverlay;
103+ uint8* fBuffer;
104+
105+ int32 fWidth;
106+ int32 fHeight;
107+ int32 fBytesPerRow;
108+ color_space fSpace;
109+ uint32 fFlags;
110+
111+ ServerApp* fOwner;
112+ int32 fToken;
113+};
114+
115+class UtilityBitmap : public ServerBitmap {
116+public:
117+ UtilityBitmap(BRect rect, color_space space,
118+ uint32 flags, int32 bytesperline = -1,
119+ screen_id screen = B_MAIN_SCREEN_ID);
120+ UtilityBitmap(const ServerBitmap* bmp);
121+
122+ UtilityBitmap(const uint8* alreadyPaddedData,
123+ uint32 width, uint32 height,
124+ color_space format);
125+
126+ virtual ~UtilityBitmap();
127+};
128+
129+
130+//! (only for server bitmaps)
131+void
132+ServerBitmap::ShallowCopy(const ServerBitmap* from)
133+{
134+ if (!from)
135+ return;
136+
137+ fBuffer = from->fBuffer;
138+ fWidth = from->fWidth;
139+ fHeight = from->fHeight;
140+ fBytesPerRow = from->fBytesPerRow;
141+ fSpace = from->fSpace;
142+ fFlags = from->fFlags;
143+ fToken = from->fToken;
144+}
145+
146+#endif // SERVER_BITMAP_H
1@@ -0,0 +1,71 @@
2+/*
3+ * Copyright 2001-2009, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Stephan Aßmus <superstippi@gmx.de>
9+ * Axel Dörfler, axeld@pinc-software.de
10+ */
11+#ifndef SERVER_CURSOR_H
12+#define SERVER_CURSOR_H
13+
14+
15+#include "ServerBitmap.h"
16+
17+#include <Point.h>
18+#include <String.h>
19+
20+
21+class CursorManager;
22+
23+
24+class ServerCursor : public ServerBitmap {
25+public:
26+ ServerCursor(BRect r, color_space space,
27+ int32 flags, BPoint hotspot,
28+ int32 bytesPerRow = -1,
29+ screen_id screen = B_MAIN_SCREEN_ID);
30+ ServerCursor(const uint8* cursorDataFromR5);
31+ ServerCursor(const uint8* alreadyPaddedData,
32+ uint32 width, uint32 height,
33+ color_space format);
34+ ServerCursor(const ServerCursor* cursor);
35+
36+ virtual ~ServerCursor();
37+
38+ //! Returns the cursor's hot spot
39+ void SetHotSpot(BPoint pt);
40+ BPoint GetHotSpot() const
41+ { return fHotSpot; }
42+
43+ void SetOwningTeam(team_id tid)
44+ { fOwningTeam = tid; }
45+ team_id OwningTeam() const
46+ { return fOwningTeam; }
47+
48+ int32 Token() const
49+ { return fToken; }
50+
51+ void AttachedToManager(CursorManager* manager);
52+
53+ const uint8* CursorData() const
54+ { return fCursorData; }
55+
56+protected:
57+ virtual void LastReferenceReleased();
58+
59+private:
60+ friend class CursorManager;
61+
62+ BPoint fHotSpot;
63+ team_id fOwningTeam;
64+ uint8* fCursorData;
65+ CursorManager* fManager;
66+};
67+
68+
69+typedef BReference<ServerCursor> ServerCursorReference;
70+
71+
72+#endif // SERVER_CURSOR_H
+203,
-0
1@@ -0,0 +1,203 @@
2+/*
3+ * Copyright 2001-2008, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Jérôme Duval, jerome.duval@free.fr
9+ * Axel Dörfler, axeld@pinc-software.de
10+ * Stephan Aßmus <superstippi@gmx.de>
11+ */
12+#ifndef SERVER_FONT_H
13+#define SERVER_FONT_H
14+
15+
16+#include <Font.h>
17+#include <Rect.h>
18+
19+#include "FontFamily.h"
20+#include "GlobalSubpixelSettings.h"
21+#include "Transformable.h"
22+
23+class BShape;
24+class BString;
25+
26+
27+class ServerFont {
28+ public:
29+ ServerFont();
30+ ServerFont(FontStyle& style,
31+ float size = 12.0, float rotation = 0.0,
32+ float shear = 90.0,
33+ float falseBoldWidth = 0.0,
34+ uint16 flags = 0,
35+ uint8 spacing = B_BITMAP_SPACING);
36+ ServerFont(const ServerFont& font);
37+ virtual ~ServerFont();
38+
39+ ServerFont &operator=(const ServerFont& font);
40+ bool operator==(const ServerFont& other) const;
41+
42+ font_direction Direction() const
43+ { return fDirection; }
44+ uint32 Encoding() const
45+ { return fEncoding; }
46+ uint32 Flags() const
47+ { return fFlags; }
48+ uint32 Spacing() const
49+ { return fSpacing; }
50+ float Shear() const
51+ { return fShear; }
52+ float Rotation() const
53+ { return fRotation; }
54+ float FalseBoldWidth() const
55+ { return fFalseBoldWidth; }
56+ float Size() const
57+ { return fSize; }
58+ uint16 Face() const
59+ { return fFace; }
60+ uint32 CountGlyphs()
61+ { return fStyle->GlyphCount(); }
62+ int32 CountTuned();
63+
64+ font_file_format FileFormat();
65+
66+ const char* Style() const;
67+ const char* Family() const;
68+ const char* Path() const
69+ { return fStyle->Path(); }
70+
71+ void SetStyle(FontStyle* style);
72+ status_t SetFamilyAndStyle(uint16 familyID,
73+ uint16 styleID);
74+ status_t SetFamilyAndStyle(uint32 fontID);
75+
76+ uint16 StyleID() const
77+ { return fStyle->ID(); }
78+ uint16 FamilyID() const
79+ { return fStyle->Family()->ID(); }
80+ uint32 GetFamilyAndStyle() const;
81+
82+ void SetDirection(font_direction dir)
83+ { fDirection = dir; }
84+ void SetEncoding(uint32 encoding)
85+ { fEncoding = encoding; }
86+ void SetFlags(uint32 value)
87+ { fFlags = value; }
88+ void SetSpacing(uint32 value)
89+ { fSpacing = value; }
90+ void SetShear(float value)
91+ { fShear = value; }
92+ void SetSize(float value)
93+ { fSize = value; }
94+ void SetRotation(float value)
95+ { fRotation = value; }
96+ void SetFalseBoldWidth(float value)
97+ { fFalseBoldWidth = value; }
98+ status_t SetFace(uint16 face);
99+
100+ bool IsFixedWidth() const
101+ { return fStyle->IsFixedWidth(); }
102+ bool IsScalable() const
103+ { return fStyle->IsScalable(); }
104+ bool HasKerning() const
105+ { return fStyle->HasKerning(); }
106+ bool HasTuned() const
107+ { return fStyle->HasTuned(); }
108+ int32 TunedCount() const
109+ { return fStyle->TunedCount(); }
110+ uint16 GlyphCount() const
111+ { return fStyle->GlyphCount(); }
112+ uint16 CharMapCount() const
113+ { return fStyle->CharMapCount(); }
114+ inline bool Hinting() const;
115+
116+ status_t GetGlyphShapes(const char charArray[],
117+ int32 numChars, BShape *shapeArray[]) const;
118+
119+ status_t GetHasGlyphs(const char charArray[],
120+ int32 numBytes, int32 numChars,
121+ bool hasArray[]) const;
122+
123+ status_t GetEdges(const char charArray[], int32 numBytes,
124+ int32 numChars, edge_info edgeArray[])
125+ const;
126+
127+ status_t GetEscapements(const char charArray[],
128+ int32 numBytes, int32 numChars,
129+ escapement_delta delta,
130+ BPoint escapementArray[],
131+ BPoint offsetArray[]) const;
132+
133+ status_t GetEscapements(const char charArray[],
134+ int32 numBytes, int32 numChars,
135+ escapement_delta delta,
136+ float widthArray[]) const;
137+
138+ status_t GetBoundingBoxes(const char charArray[],
139+ int32 numBytes, int32 numChars,
140+ BRect rectArray[], bool stringEscapement,
141+ font_metric_mode mode,
142+ escapement_delta delta,
143+ bool asString);
144+
145+ status_t GetBoundingBoxesForStrings(char *charArray[],
146+ size_t lengthArray[], int32 numStrings,
147+ BRect rectArray[], font_metric_mode mode,
148+ escapement_delta deltaArray[]);
149+
150+ float StringWidth(const char *string,
151+ int32 numBytes,
152+ const escapement_delta* delta = NULL) const;
153+
154+ bool Lock() const { return fStyle->Lock(); }
155+ void Unlock() const { fStyle->Unlock(); }
156+
157+// FT_Face GetFTFace() const
158+// { return fStyle->FreeTypeFace(); };
159+
160+ BRect BoundingBox();
161+ void GetHeight(font_height& height) const;
162+
163+ void TruncateString(BString* inOut,
164+ uint32 mode, float width) const;
165+
166+ Transformable EmbeddedTransformation() const;
167+ status_t GetUnicodeBlocks(unicode_block &blocksForFont);
168+ status_t IncludesUnicodeBlock(uint32 start, uint32 end,
169+ bool &hasBlock);
170+
171+protected:
172+ friend class FontStyle;
173+ FT_Face GetTransformedFace(bool rotate,
174+ bool shear) const;
175+ void PutTransformedFace(FT_Face face) const;
176+
177+ BReference<FontStyle>
178+ fStyle;
179+ float fSize;
180+ float fRotation;
181+ float fShear;
182+ float fFalseBoldWidth;
183+ BRect fBounds;
184+ uint32 fFlags;
185+ uint32 fSpacing;
186+ font_direction fDirection;
187+ uint16 fFace;
188+ uint32 fEncoding;
189+};
190+
191+inline bool ServerFont::Hinting() const
192+{
193+ switch (gDefaultHintingMode) {
194+ case HINTING_MODE_OFF:
195+ return false;
196+ default:
197+ case HINTING_MODE_ON:
198+ return true;
199+ case HINTING_MODE_MONOSPACED_ONLY:
200+ return IsFixedWidth();
201+ }
202+}
203+
204+#endif /* SERVER_FONT_H */
+246,
-0
1@@ -0,0 +1,246 @@
2+/*
3+ * Copyright 2001-2007, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Pahtz <pahtz@yahoo.com.au>
9+ * Axel Dörfler, axeld@pinc-software.de
10+ */
11+#ifndef _SERVER_LINK_H
12+#define _SERVER_LINK_H
13+
14+
15+#include <OS.h>
16+#include <LinkReceiver.h>
17+#include <LinkSender.h>
18+
19+class BShape;
20+class BString;
21+class BGradient;
22+
23+/*
24+ * Error checking rules: (for if you don't want to check every return code)
25+ * - Calling EndMessage() is optional, implied by Flush() or StartMessage().
26+ * - If you are sending just one message you only need to test Flush() == B_OK
27+ * - If you are buffering multiple messages without calling Flush() you must
28+ * check EndMessage() == B_OK, or the last Attach() for each message.
29+ * Check Flush() at the end.
30+ * - If you are reading, check the last Read() or ReadString() you perform.
31+ */
32+
33+namespace BPrivate {
34+
35+class ServerLink {
36+public:
37+ ServerLink();
38+ virtual ~ServerLink();
39+
40+ void SetTo(port_id sender, port_id receiver);
41+
42+ // send methods
43+
44+ void SetSenderPort(port_id port);
45+ port_id SenderPort();
46+
47+ void SetTargetTeam(team_id team);
48+ team_id TargetTeam();
49+
50+ status_t StartMessage(int32 code, size_t minSize = 0);
51+ void CancelMessage();
52+ status_t EndMessage();
53+
54+ status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT,
55+ bool needsReply = false);
56+ status_t Attach(const void* data, ssize_t size);
57+ status_t AttachString(const char* string,
58+ int32 length = -1);
59+ status_t AttachRegion(const BRegion& region);
60+ status_t AttachShape(BShape& shape);
61+ status_t AttachGradient(const BGradient& gradient);
62+
63+ template <class Type>
64+ status_t Attach(const Type& data);
65+
66+ // receive methods
67+
68+ void SetReceiverPort(port_id port);
69+ port_id ReceiverPort();
70+
71+ status_t GetNextMessage(int32& code,
72+ bigtime_t timeout = B_INFINITE_TIMEOUT);
73+ bool NeedsReply() const;
74+ status_t Read(void* data, ssize_t size);
75+ status_t ReadString(char* buffer, size_t bufferSize);
76+ status_t ReadString(BString& string,
77+ size_t* _length = NULL);
78+ status_t ReadString(char** _string,
79+ size_t* _length = NULL);
80+ status_t ReadRegion(BRegion* region);
81+ status_t ReadShape(BShape* shape);
82+ status_t ReadGradient(BGradient** _gradient);
83+
84+ template <class Type>
85+ status_t Read(Type* data);
86+
87+ // convenience methods
88+
89+ status_t FlushWithReply(int32& code);
90+ LinkSender& Sender() { return *fSender; }
91+ LinkReceiver& Receiver() { return *fReceiver; }
92+
93+protected:
94+ LinkSender* fSender;
95+ LinkReceiver* fReceiver;
96+};
97+
98+
99+// #pragma mark - sender inline functions
100+
101+
102+inline void
103+ServerLink::SetSenderPort(port_id port)
104+{
105+ fSender->SetPort(port);
106+}
107+
108+
109+inline port_id
110+ServerLink::SenderPort()
111+{
112+ return fSender->Port();
113+}
114+
115+
116+inline void
117+ServerLink::SetTargetTeam(team_id team)
118+{
119+ fSender->SetTargetTeam(team);
120+}
121+
122+
123+inline team_id
124+ServerLink::TargetTeam()
125+{
126+ return fSender->TargetTeam();
127+}
128+
129+
130+inline status_t
131+ServerLink::StartMessage(int32 code, size_t minSize)
132+{
133+ return fSender->StartMessage(code, minSize);
134+}
135+
136+
137+inline status_t
138+ServerLink::EndMessage()
139+{
140+ return fSender->EndMessage();
141+}
142+
143+
144+inline void
145+ServerLink::CancelMessage()
146+{
147+ fSender->CancelMessage();
148+}
149+
150+
151+inline status_t
152+ServerLink::Flush(bigtime_t timeout, bool needsReply)
153+{
154+ return fSender->Flush(timeout, needsReply);
155+}
156+
157+
158+inline status_t
159+ServerLink::Attach(const void* data, ssize_t size)
160+{
161+ return fSender->Attach(data, size);
162+}
163+
164+
165+inline status_t
166+ServerLink::AttachString(const char* string, int32 length)
167+{
168+ return fSender->AttachString(string, length);
169+}
170+
171+
172+template<class Type> status_t
173+ServerLink::Attach(const Type& data)
174+{
175+ return Attach(&data, sizeof(Type));
176+}
177+
178+
179+// #pragma mark - receiver inline functions
180+
181+
182+inline void
183+ServerLink::SetReceiverPort(port_id port)
184+{
185+ fReceiver->SetPort(port);
186+}
187+
188+
189+inline port_id
190+ServerLink::ReceiverPort()
191+{
192+ return fReceiver->Port();
193+}
194+
195+
196+inline status_t
197+ServerLink::GetNextMessage(int32& code, bigtime_t timeout)
198+{
199+ return fReceiver->GetNextMessage(code, timeout);
200+}
201+
202+
203+inline bool
204+ServerLink::NeedsReply() const
205+{
206+ return fReceiver->NeedsReply();
207+}
208+
209+
210+inline status_t
211+ServerLink::Read(void* data, ssize_t size)
212+{
213+ return fReceiver->Read(data, size);
214+}
215+
216+
217+inline status_t
218+ServerLink::ReadString(char* buffer, size_t bufferSize)
219+{
220+ return fReceiver->ReadString(buffer, bufferSize);
221+}
222+
223+
224+inline status_t
225+ServerLink::ReadString(BString& string, size_t* _length)
226+{
227+ return fReceiver->ReadString(string, _length);
228+}
229+
230+
231+inline status_t
232+ServerLink::ReadString(char** _string, size_t* _length)
233+{
234+ return fReceiver->ReadString(_string, _length);
235+}
236+
237+
238+template <class Type> status_t
239+ServerLink::Read(Type* data)
240+{
241+ return Read(data, sizeof(Type));
242+}
243+
244+
245+} // namespace BPrivate
246+
247+#endif /* _SERVER_LINK_H */
+394,
-0
1@@ -0,0 +1,394 @@
2+/*
3+ * Copyright 2001-2016, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * DarkWyrm <bpmagic@columbus.rr.com>
8+ * Jérôme Duval, jerome.duval@free.fr
9+ * Axel Dörfler, axeld@pinc-software.de
10+ * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
11+ * Julian Harnath, <julian.harnath@rwth-aachen.de>
12+ */
13+#ifndef APP_SERVER_PROTOCOL_H
14+#define APP_SERVER_PROTOCOL_H
15+
16+
17+#include <SupportDefs.h>
18+
19+
20+#ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST
21+# define SERVER_PORT_NAME "haiku-test:app_server"
22+#endif
23+
24+#if TEST_MODE
25+# define SERVER_INPUT_PORT "haiku-test:input port"
26+#endif
27+
28+#define AS_PROTOCOL_VERSION 1
29+
30+#define AS_REQUEST_COLOR_KEY 0x00010000
31+ // additional option for AS_VIEW_SET_VIEW_BITMAP
32+
33+enum {
34+ // NOTE: all defines have to start with "AS_" to let the "code_to_name"
35+ // utility work correctly
36+
37+ AS_GET_DESKTOP,
38+ AS_REGISTER_INPUT_SERVER = 1,
39+ AS_EVENT_STREAM_CLOSED,
40+ // Notification of event stream closing to restart input_server
41+
42+ // Desktop definitions (through the ServerApp, though)
43+ AS_GET_WINDOW_LIST,
44+ AS_GET_WINDOW_INFO,
45+ AS_MINIMIZE_TEAM,
46+ AS_BRING_TEAM_TO_FRONT,
47+ AS_WINDOW_ACTION,
48+ AS_GET_APPLICATION_ORDER,
49+ AS_GET_WINDOW_ORDER,
50+
51+ // Application definitions
52+ AS_CREATE_APP,
53+ AS_DELETE_APP,
54+ AS_QUIT_APP,
55+ AS_ACTIVATE_APP,
56+ AS_APP_CRASHED,
57+
58+ AS_CREATE_WINDOW,
59+ AS_CREATE_OFFSCREEN_WINDOW,
60+ AS_DELETE_WINDOW,
61+ AS_CREATE_BITMAP,
62+ AS_DELETE_BITMAP,
63+ AS_GET_BITMAP_OVERLAY_RESTRICTIONS,
64+ AS_GET_BITMAP_SUPPORT_FLAGS,
65+ AS_RECONNECT_BITMAP,
66+
67+ // Cursor commands
68+ AS_SET_CURSOR,
69+ AS_SET_VIEW_CURSOR,
70+
71+ AS_SHOW_CURSOR,
72+ AS_HIDE_CURSOR,
73+ AS_OBSCURE_CURSOR,
74+ AS_QUERY_CURSOR_HIDDEN,
75+
76+ AS_CREATE_CURSOR,
77+ AS_CREATE_CURSOR_BITMAP,
78+ AS_REFERENCE_CURSOR,
79+ AS_DELETE_CURSOR,
80+
81+ AS_BEGIN_RECT_TRACKING,
82+ AS_END_RECT_TRACKING,
83+
84+ AS_GET_CURSOR_POSITION,
85+ AS_GET_CURSOR_BITMAP,
86+
87+ // Window definitions
88+ AS_SHOW_OR_HIDE_WINDOW,
89+ AS_INTERNAL_HIDE_WINDOW,
90+ AS_MINIMIZE_WINDOW,
91+ AS_QUIT_WINDOW,
92+ AS_SEND_BEHIND,
93+ AS_SET_LOOK,
94+ AS_SET_FEEL,
95+ AS_SET_FLAGS,
96+ AS_DISABLE_UPDATES,
97+ AS_ENABLE_UPDATES,
98+ AS_BEGIN_UPDATE,
99+ AS_END_UPDATE,
100+ AS_NEEDS_UPDATE,
101+ AS_SET_WINDOW_TITLE,
102+ AS_ADD_TO_SUBSET,
103+ AS_REMOVE_FROM_SUBSET,
104+ AS_SET_ALIGNMENT,
105+ AS_GET_ALIGNMENT,
106+ AS_GET_WORKSPACES,
107+ AS_SET_WORKSPACES,
108+ AS_WINDOW_RESIZE,
109+ AS_WINDOW_MOVE,
110+ AS_SET_SIZE_LIMITS,
111+ AS_ACTIVATE_WINDOW,
112+ AS_IS_FRONT_WINDOW,
113+
114+ // BPicture definitions
115+ AS_CREATE_PICTURE,
116+ AS_DELETE_PICTURE,
117+ AS_CLONE_PICTURE,
118+ AS_DOWNLOAD_PICTURE,
119+
120+ // Font-related server communications
121+ AS_SET_SYSTEM_FONT,
122+ AS_GET_SYSTEM_FONTS,
123+ AS_GET_SYSTEM_DEFAULT_FONT,
124+ AS_SYSTEM_FONT_CHANGED,
125+
126+ AS_GET_FONT_LIST_REVISION,
127+ AS_GET_FAMILY_AND_STYLES,
128+
129+ AS_GET_FAMILY_AND_STYLE,
130+ AS_GET_FAMILY_AND_STYLE_IDS,
131+ AS_GET_FONT_BOUNDING_BOX,
132+ AS_GET_TUNED_COUNT,
133+ AS_GET_TUNED_INFO,
134+ AS_GET_FONT_HEIGHT,
135+ AS_GET_FONT_FILE_FORMAT,
136+ AS_GET_EXTRA_FONT_FLAGS,
137+
138+ AS_GET_STRING_WIDTHS,
139+ AS_GET_EDGES,
140+ AS_GET_ESCAPEMENTS,
141+ AS_GET_ESCAPEMENTS_AS_FLOATS,
142+ AS_GET_BOUNDINGBOXES_CHARS,
143+ AS_GET_BOUNDINGBOXES_STRING,
144+ AS_GET_BOUNDINGBOXES_STRINGS,
145+ AS_GET_HAS_GLYPHS,
146+ AS_GET_GLYPH_SHAPES,
147+ AS_GET_TRUNCATED_STRINGS,
148+ AS_GET_UNICODE_BLOCKS,
149+ AS_GET_HAS_UNICODE_BLOCK,
150+
151+ // Screen methods
152+ AS_VALID_SCREEN_ID,
153+ AS_GET_NEXT_SCREEN_ID,
154+ AS_SCREEN_GET_MODE,
155+ AS_SCREEN_SET_MODE,
156+ AS_PROPOSE_MODE,
157+ AS_GET_MODE_LIST,
158+ AS_GET_SCREEN_FRAME,
159+
160+ AS_GET_PIXEL_CLOCK_LIMITS,
161+ AS_GET_TIMING_CONSTRAINTS,
162+
163+ AS_SCREEN_GET_COLORMAP,
164+ AS_GET_DESKTOP_COLOR,
165+ AS_SET_DESKTOP_COLOR,
166+ AS_GET_SCREEN_ID_FROM_WINDOW,
167+
168+ AS_READ_BITMAP,
169+
170+ AS_GET_RETRACE_SEMAPHORE,
171+ AS_GET_ACCELERANT_INFO,
172+ AS_GET_MONITOR_INFO,
173+ AS_GET_FRAME_BUFFER_CONFIG,
174+
175+ AS_SET_DPMS,
176+ AS_GET_DPMS_STATE,
177+ AS_GET_DPMS_CAPABILITIES,
178+
179+ AS_SCREEN_SET_BRIGHTNESS,
180+ AS_SCREEN_GET_BRIGHTNESS,
181+
182+ // Misc stuff
183+ AS_GET_ACCELERANT_PATH,
184+ AS_GET_DRIVER_PATH,
185+
186+ // Global function call defs
187+ AS_SET_UI_COLORS,
188+ AS_SET_UI_COLOR,
189+ AS_SET_DECORATOR,
190+ AS_GET_DECORATOR,
191+ AS_R5_SET_DECORATOR,
192+ AS_COUNT_DECORATORS,
193+ AS_GET_DECORATOR_NAME,
194+ AS_SET_CONTROL_LOOK,
195+ AS_GET_CONTROL_LOOK,
196+
197+ AS_COUNT_WORKSPACES,
198+ AS_CURRENT_WORKSPACE,
199+ AS_ACTIVATE_WORKSPACE,
200+ AS_SET_WORKSPACE_LAYOUT,
201+ AS_GET_WORKSPACE_LAYOUT,
202+ AS_GET_SCROLLBAR_INFO,
203+ AS_SET_SCROLLBAR_INFO,
204+ AS_GET_MENU_INFO,
205+ AS_SET_MENU_INFO,
206+ AS_IDLE_TIME,
207+ AS_SET_MOUSE_MODE,
208+ AS_GET_MOUSE_MODE,
209+ AS_SET_FOCUS_FOLLOWS_MOUSE_MODE,
210+ AS_GET_FOCUS_FOLLOWS_MOUSE_MODE,
211+ AS_SET_ACCEPT_FIRST_CLICK,
212+ AS_GET_ACCEPT_FIRST_CLICK,
213+ AS_GET_MOUSE,
214+ AS_SET_DECORATOR_SETTINGS,
215+ AS_GET_DECORATOR_SETTINGS,
216+ AS_GET_SHOW_ALL_DRAGGERS,
217+ AS_SET_SHOW_ALL_DRAGGERS,
218+
219+ // Subpixel antialiasing & hinting
220+ AS_SET_SUBPIXEL_ANTIALIASING,
221+ AS_GET_SUBPIXEL_ANTIALIASING,
222+ AS_SET_HINTING,
223+ AS_GET_HINTING,
224+ AS_SET_SUBPIXEL_AVERAGE_WEIGHT,
225+ AS_GET_SUBPIXEL_AVERAGE_WEIGHT,
226+ AS_SET_SUBPIXEL_ORDERING,
227+ AS_GET_SUBPIXEL_ORDERING,
228+
229+ // Graphics calls
230+ AS_SET_HIGH_COLOR,
231+ AS_SET_LOW_COLOR,
232+ AS_SET_VIEW_COLOR,
233+
234+ AS_STROKE_ARC,
235+ AS_STROKE_BEZIER,
236+ AS_STROKE_ELLIPSE,
237+ AS_STROKE_LINE,
238+ AS_STROKE_LINEARRAY,
239+ AS_STROKE_POLYGON,
240+ AS_STROKE_RECT,
241+ AS_STROKE_ROUNDRECT,
242+ AS_STROKE_SHAPE,
243+ AS_STROKE_TRIANGLE,
244+
245+ AS_FILL_ARC,
246+ AS_FILL_ARC_GRADIENT,
247+ AS_FILL_BEZIER,
248+ AS_FILL_BEZIER_GRADIENT,
249+ AS_FILL_ELLIPSE,
250+ AS_FILL_ELLIPSE_GRADIENT,
251+ AS_FILL_POLYGON,
252+ AS_FILL_POLYGON_GRADIENT,
253+ AS_FILL_RECT,
254+ AS_FILL_RECT_GRADIENT,
255+ AS_FILL_REGION,
256+ AS_FILL_REGION_GRADIENT,
257+ AS_FILL_ROUNDRECT,
258+ AS_FILL_ROUNDRECT_GRADIENT,
259+ AS_FILL_SHAPE,
260+ AS_FILL_SHAPE_GRADIENT,
261+ AS_FILL_TRIANGLE,
262+ AS_FILL_TRIANGLE_GRADIENT,
263+
264+ AS_DRAW_STRING,
265+ AS_DRAW_STRING_WITH_DELTA,
266+ AS_DRAW_STRING_WITH_OFFSETS,
267+
268+ AS_SYNC,
269+
270+ AS_VIEW_CREATE,
271+ AS_VIEW_DELETE,
272+ AS_VIEW_CREATE_ROOT,
273+ AS_VIEW_SHOW,
274+ AS_VIEW_HIDE,
275+ AS_VIEW_MOVE,
276+ AS_VIEW_RESIZE,
277+ AS_VIEW_DRAW,
278+
279+ // View/Layer definitions
280+ AS_VIEW_GET_COORD,
281+ AS_VIEW_SET_FLAGS,
282+ AS_VIEW_SET_ORIGIN,
283+ AS_VIEW_GET_ORIGIN,
284+ AS_VIEW_RESIZE_MODE,
285+ AS_VIEW_BEGIN_RECT_TRACK,
286+ AS_VIEW_END_RECT_TRACK,
287+ AS_VIEW_DRAG_RECT,
288+ AS_VIEW_DRAG_IMAGE,
289+ AS_VIEW_SCROLL,
290+ AS_VIEW_SET_LINE_MODE,
291+ AS_VIEW_GET_LINE_MODE,
292+ AS_VIEW_PUSH_STATE,
293+ AS_VIEW_POP_STATE,
294+ AS_VIEW_SET_SCALE,
295+ AS_VIEW_GET_SCALE,
296+ AS_VIEW_SET_DRAWING_MODE,
297+ AS_VIEW_GET_DRAWING_MODE,
298+ AS_VIEW_SET_BLENDING_MODE,
299+ AS_VIEW_GET_BLENDING_MODE,
300+ AS_VIEW_SET_PEN_LOC,
301+ AS_VIEW_GET_PEN_LOC,
302+ AS_VIEW_SET_PEN_SIZE,
303+ AS_VIEW_GET_PEN_SIZE,
304+ AS_VIEW_SET_HIGH_COLOR,
305+ AS_VIEW_SET_HIGH_UI_COLOR,
306+ AS_VIEW_SET_LOW_COLOR,
307+ AS_VIEW_SET_LOW_UI_COLOR,
308+ AS_VIEW_SET_VIEW_COLOR,
309+ AS_VIEW_SET_VIEW_UI_COLOR,
310+ AS_VIEW_GET_HIGH_COLOR,
311+ AS_VIEW_GET_HIGH_UI_COLOR,
312+ AS_VIEW_GET_LOW_COLOR,
313+ AS_VIEW_GET_LOW_UI_COLOR,
314+ AS_VIEW_GET_VIEW_COLOR,
315+ AS_VIEW_GET_VIEW_UI_COLOR,
316+
317+ AS_VIEW_PRINT_ALIASING,
318+ AS_VIEW_CLIP_TO_PICTURE,
319+ AS_VIEW_GET_CLIP_REGION,
320+ AS_VIEW_DRAW_BITMAP,
321+ AS_VIEW_SET_EVENT_MASK,
322+ AS_VIEW_SET_MOUSE_EVENT_MASK,
323+
324+ AS_VIEW_DRAW_STRING,
325+ AS_VIEW_SET_CLIP_REGION,
326+ AS_VIEW_LINE_ARRAY,
327+ AS_VIEW_BEGIN_PICTURE,
328+ AS_VIEW_APPEND_TO_PICTURE,
329+ AS_VIEW_END_PICTURE,
330+ AS_VIEW_COPY_BITS,
331+ AS_VIEW_DRAW_PICTURE,
332+ AS_VIEW_INVALIDATE_RECT,
333+ AS_VIEW_DELAYED_INVALIDATE_RECT,
334+ AS_VIEW_INVALIDATE_REGION,
335+ AS_VIEW_INVERT_RECT,
336+ AS_VIEW_MOVE_TO,
337+ AS_VIEW_RESIZE_TO,
338+ AS_VIEW_SET_STATE,
339+ AS_VIEW_SET_FONT_STATE,
340+ AS_VIEW_GET_STATE,
341+ AS_VIEW_SET_VIEW_BITMAP,
342+ AS_VIEW_SET_PATTERN,
343+ AS_SET_CURRENT_VIEW,
344+ AS_VIEW_BEGIN_LAYER,
345+ AS_VIEW_END_LAYER,
346+
347+ // BDirectWindow/BWindowScreen codes
348+ AS_DIRECT_WINDOW_GET_SYNC_DATA,
349+ AS_DIRECT_WINDOW_SET_FULLSCREEN,
350+ AS_DIRECT_SCREEN_LOCK,
351+
352+ // desktop listener communications
353+ AS_TALK_TO_DESKTOP_LISTENER,
354+
355+ // debugging helper
356+ AS_DUMP_ALLOCATOR,
357+ AS_DUMP_BITMAPS,
358+
359+ // transformation in addition to origin/scale
360+ AS_VIEW_SET_TRANSFORM,
361+ AS_VIEW_GET_TRANSFORM,
362+
363+ AS_VIEW_AFFINE_TRANSLATE,
364+ AS_VIEW_AFFINE_SCALE,
365+ AS_VIEW_AFFINE_ROTATE,
366+
367+ // Polygon filling rules
368+ AS_VIEW_SET_FILL_RULE,
369+ AS_VIEW_GET_FILL_RULE,
370+
371+ // New clipping: cumulative, transformed
372+ AS_VIEW_CLIP_TO_RECT,
373+ AS_VIEW_CLIP_TO_SHAPE,
374+
375+ // Internal messages
376+ AS_COLOR_MAP_UPDATED,
377+
378+ AS_LAST_CODE
379+};
380+
381+// TODO: move this into a private app header, together with the rest of the
382+// private message definitions in AppDefs.h
383+enum {
384+ kMsgDeleteServerMemoryArea = '_DSA',
385+};
386+
387+// bitmap allocation flags
388+enum {
389+ kAllocator = 0x1,
390+ kFramebuffer = 0x2,
391+ kHeap = 0x4,
392+ kNewAllocatorArea = 0x8,
393+};
394+
395+#endif // APP_SERVER_PROTOCOL_H
1@@ -0,0 +1,116 @@
2+/*
3+ * Copyright 2009, Haiku. All rights reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, <superstippi@gmx.de>
8+ */
9+#ifndef APP_SERVER_PROTOCOL_STRUCTS_H
10+#define APP_SERVER_PROTOCOL_STRUCTS_H
11+
12+
13+#include <AffineTransform.h>
14+#include <Rect.h>
15+
16+
17+struct ViewSetStateInfo {
18+ BPoint penLocation;
19+ float penSize;
20+ rgb_color highColor;
21+ rgb_color lowColor;
22+ color_which whichHighColor;
23+ color_which whichLowColor;
24+ float whichHighColorTint;
25+ float whichLowColorTint;
26+ ::pattern pattern;
27+ drawing_mode drawingMode;
28+ BPoint origin;
29+ float scale;
30+ join_mode lineJoin;
31+ cap_mode lineCap;
32+ float miterLimit;
33+ int32 fillRule;
34+ source_alpha alphaSourceMode;
35+ alpha_function alphaFunctionMode;
36+ bool fontAntialiasing;
37+};
38+
39+
40+struct ViewGetStateInfo {
41+ int32 fontID;
42+ float fontSize;
43+ float fontShear;
44+ float fontRotation;
45+ float fontFalseBoldWidth;
46+ int8 fontSpacing;
47+ int8 fontEncoding;
48+ int16 fontFace;
49+ int32 fontFlags;
50+
51+ ViewSetStateInfo viewStateInfo;
52+};
53+
54+
55+struct ViewDragImageInfo {
56+ int32 bitmapToken;
57+ int32 dragMode;
58+ BPoint offset;
59+ int32 bufferSize;
60+};
61+
62+
63+struct ViewSetViewCursorInfo {
64+ int32 cursorToken;
65+ int32 viewToken;
66+ bool sync;
67+};
68+
69+
70+struct ViewBeginRectTrackingInfo {
71+ BRect rect;
72+ uint32 style;
73+};
74+
75+
76+struct ViewSetLineModeInfo {
77+ join_mode lineJoin;
78+ cap_mode lineCap;
79+ float miterLimit;
80+};
81+
82+
83+struct ViewBlendingModeInfo {
84+ source_alpha sourceAlpha;
85+ alpha_function alphaFunction;
86+};
87+
88+
89+struct ViewDrawBitmapInfo {
90+ int32 bitmapToken;
91+ uint32 options;
92+ BRect viewRect;
93+ BRect bitmapRect;
94+};
95+
96+
97+struct ViewDrawStringInfo {
98+ int32 stringLength;
99+ BPoint location;
100+ escapement_delta delta;
101+};
102+
103+
104+struct ViewStrokeLineInfo {
105+ BPoint startPoint;
106+ BPoint endPoint;
107+};
108+
109+
110+struct ViewLineArrayInfo {
111+ BPoint startPoint;
112+ BPoint endPoint;
113+ rgb_color color;
114+};
115+
116+
117+#endif // APP_SERVER_PROTOCOL_STRUCTS_H
1@@ -0,0 +1,243 @@
2+/*
3+ * Copyright (c) 2001-2015, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ * Stephan Aßmus <superstippi@gmx.de>
9+ * Adrien Destugues <pulkomandy@pulkomandy.tk>
10+ * Julian Harnath <julian.harnath@rwth-aachen.de>
11+ */
12+
13+#ifndef SIMPLE_TRANSFORM_H
14+#define SIMPLE_TRANSFORM_H
15+
16+#include <GradientLinear.h>
17+#include <GradientRadial.h>
18+#include <GradientRadialFocus.h>
19+#include <GradientDiamond.h>
20+#include <GradientConic.h>
21+#include <Point.h>
22+#include <Region.h>
23+
24+#include "IntPoint.h"
25+#include "IntRect.h"
26+
27+
28+class SimpleTransform {
29+public:
30+ SimpleTransform()
31+ :
32+ fScale(1.0)
33+ {
34+ }
35+
36+ void AddOffset(float x, float y)
37+ {
38+ fOffset.x += x;
39+ fOffset.y += y;
40+ }
41+
42+ void SetScale(float scale)
43+ {
44+ fScale = scale;
45+ }
46+
47+ void Apply(BPoint* point) const
48+ {
49+ _Apply(point->x, point->y);
50+ }
51+
52+ void Apply(IntPoint* point) const
53+ {
54+ _Apply(point->x, point->y);
55+ }
56+
57+ void Apply(BRect* rect) const
58+ {
59+ if (fScale == 1.0) {
60+ rect->OffsetBy(fOffset.x, fOffset.y);
61+ } else {
62+ _Apply(rect->left, rect->top);
63+ _Apply(rect->right, rect->bottom);
64+ }
65+ }
66+
67+ void Apply(IntRect* rect) const
68+ {
69+ if (fScale == 1.0) {
70+ rect->OffsetBy(fOffset.x, fOffset.y);
71+ } else {
72+ _Apply(rect->left, rect->top);
73+ _Apply(rect->right, rect->bottom);
74+ }
75+ }
76+
77+ void Apply(BRegion* region) const
78+ {
79+ if (fScale == 1.0) {
80+ region->OffsetBy(fOffset.x, fOffset.y);
81+ } else {
82+ // TODO: optimize some more
83+ BRegion converted;
84+ int32 count = region->CountRects();
85+ for (int32 i = 0; i < count; i++) {
86+ BRect r = region->RectAt(i);
87+ BPoint lt(r.LeftTop());
88+ BPoint rb(r.RightBottom());
89+ // offset to bottom right corner of pixel before transformation
90+ rb.x++;
91+ rb.y++;
92+ // apply transformation
93+ _Apply(lt.x, lt.y);
94+ _Apply(rb.x, rb.y);
95+ // reset bottom right to pixel "index"
96+ rb.x--;
97+ rb.y--;
98+ // add rect to converted region
99+ // NOTE/TODO: the rect would not have to go
100+ // through the whole intersection test process,
101+ // it is guaranteed not to overlap with any rect
102+ // already contained in the region
103+ converted.Include(BRect(lt, rb));
104+ }
105+ *region = converted;
106+ }
107+ }
108+
109+ void Apply(BGradient* gradient) const
110+ {
111+ switch (gradient->GetType()) {
112+ case BGradient::TYPE_LINEAR:
113+ {
114+ BGradientLinear* linear = (BGradientLinear*) gradient;
115+ BPoint start = linear->Start();
116+ BPoint end = linear->End();
117+ Apply(&start);
118+ Apply(&end);
119+ linear->SetStart(start);
120+ linear->SetEnd(end);
121+ break;
122+ }
123+
124+ case BGradient::TYPE_RADIAL:
125+ {
126+ BGradientRadial* radial = (BGradientRadial*) gradient;
127+ BPoint center = radial->Center();
128+ Apply(¢er);
129+ radial->SetCenter(center);
130+ break;
131+ }
132+
133+ case BGradient::TYPE_RADIAL_FOCUS:
134+ {
135+ BGradientRadialFocus* radialFocus =
136+ (BGradientRadialFocus*)gradient;
137+ BPoint center = radialFocus->Center();
138+ BPoint focal = radialFocus->Focal();
139+ Apply(¢er);
140+ Apply(&focal);
141+ radialFocus->SetCenter(center);
142+ radialFocus->SetFocal(focal);
143+ break;
144+ }
145+
146+ case BGradient::TYPE_DIAMOND:
147+ {
148+ BGradientDiamond* diamond = (BGradientDiamond*) gradient;
149+ BPoint center = diamond->Center();
150+ Apply(¢er);
151+ diamond->SetCenter(center);
152+ break;
153+ }
154+
155+ case BGradient::TYPE_CONIC:
156+ {
157+ BGradientConic* conic = (BGradientConic*) gradient;
158+ BPoint center = conic->Center();
159+ Apply(¢er);
160+ conic->SetCenter(center);
161+ break;
162+ }
163+
164+ case BGradient::TYPE_NONE:
165+ {
166+ break;
167+ }
168+ }
169+
170+ // Make sure the gradient is fully padded so that out of bounds access
171+ // get the correct colors
172+ gradient->SortColorStopsByOffset();
173+
174+ BGradient::ColorStop* end = gradient->ColorStopAtFast(
175+ gradient->CountColorStops() - 1);
176+
177+ if (end->offset != 255)
178+ gradient->AddColor(end->color, 255);
179+
180+ BGradient::ColorStop* start = gradient->ColorStopAtFast(0);
181+
182+ if (start->offset != 0)
183+ gradient->AddColor(start->color, 0);
184+
185+ gradient->SortColorStopsByOffset();
186+ }
187+
188+ void Apply(BPoint* destination, const BPoint* source, int32 count) const
189+ {
190+ // TODO: optimize this, it should be smarter
191+ while (count--) {
192+ *destination = *source;
193+ Apply(destination);
194+ source++;
195+ destination++;
196+ }
197+ }
198+
199+ void Apply(BRect* destination, const BRect* source, int32 count) const
200+ {
201+ // TODO: optimize this, it should be smarter
202+ while (count--) {
203+ *destination = *source;
204+ Apply(destination);
205+ source++;
206+ destination++;
207+ }
208+ }
209+
210+ void Apply(BRegion* destination, const BRegion* source, int32 count) const
211+ {
212+ // TODO: optimize this, it should be smarter
213+ while (count--) {
214+ *destination = *source;
215+ Apply(destination);
216+ source++;
217+ destination++;
218+ }
219+ }
220+
221+private:
222+ void _Apply(int32& x, int32& y) const
223+ {
224+ x *= (int32)fScale;
225+ y *= (int32)fScale;
226+ x += (int32)fOffset.x;
227+ y += (int32)fOffset.y;
228+ }
229+
230+ void _Apply(float& x, float& y) const
231+ {
232+ x *= fScale;
233+ y *= fScale;
234+ x += fOffset.x;
235+ y += fOffset.y;
236+ }
237+
238+private:
239+ BPoint fOffset;
240+ float fScale;
241+};
242+
243+
244+#endif // SIMPLE_TRANSFORM_H
+186,
-0
1@@ -0,0 +1,186 @@
2+/*
3+ * Copyright 2010-2014 Haiku, Inc. All rights reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * John Scipione, jscipione@gmail.com
8+ * Clemens Zeidler, haiku@clemens-zeidler.de
9+ */
10+#ifndef STACK_AND_TILE_H
11+#define STACK_AND_TILE_H
12+
13+
14+#include <map>
15+
16+#include <Message.h>
17+#include <MessageFilter.h>
18+
19+#include "DesktopListener.h"
20+#include "ObjectList.h"
21+#include "WindowList.h"
22+
23+
24+//#define DEBUG_STACK_AND_TILE
25+
26+#ifdef DEBUG_STACK_AND_TILE
27+# define STRACE_SAT(x...) debug_printf("SAT: "x)
28+#else
29+# define STRACE_SAT(x...) ;
30+#endif
31+
32+
33+class SATGroup;
34+class SATWindow;
35+class Window;
36+class WindowArea;
37+
38+
39+typedef std::map<Window*, SATWindow*> SATWindowMap;
40+
41+
42+class StackAndTile : public DesktopListener {
43+public:
44+ StackAndTile();
45+ virtual ~StackAndTile();
46+
47+ virtual int32 Identifier();
48+
49+ // DesktopListener hooks
50+ virtual void ListenerRegistered(Desktop* desktop);
51+ virtual void ListenerUnregistered();
52+
53+ virtual bool HandleMessage(Window* sender,
54+ BPrivate::LinkReceiver& link,
55+ BPrivate::LinkSender& reply);
56+
57+ virtual void WindowAdded(Window* window);
58+ virtual void WindowRemoved(Window* window);
59+
60+ virtual bool KeyPressed(uint32 what, int32 key,
61+ int32 modifiers);
62+ virtual void MouseEvent(BMessage* message) {}
63+ virtual void MouseDown(Window* window, BMessage* message,
64+ const BPoint& where);
65+ virtual void MouseUp(Window* window, BMessage* message,
66+ const BPoint& where);
67+ virtual void MouseMoved(Window* window, BMessage* message,
68+ const BPoint& where) {}
69+
70+ virtual void WindowMoved(Window* window);
71+ virtual void WindowResized(Window* window);
72+ virtual void WindowActivated(Window* window);
73+ virtual void WindowSentBehind(Window* window,
74+ Window* behindOf);
75+ virtual void WindowWorkspacesChanged(Window* window,
76+ uint32 workspaces);
77+ virtual void WindowHidden(Window* window, bool fromMinimize);
78+ virtual void WindowMinimized(Window* window, bool minimize);
79+
80+ virtual void WindowTabLocationChanged(Window* window,
81+ float location, bool isShifting);
82+ virtual void SizeLimitsChanged(Window* window,
83+ int32 minWidth, int32 maxWidth,
84+ int32 minHeight, int32 maxHeight);
85+ virtual void WindowLookChanged(Window* window,
86+ window_look look);
87+ virtual void WindowFeelChanged(Window* window,
88+ window_feel feel);
89+
90+ virtual bool SetDecoratorSettings(Window* window,
91+ const BMessage& settings);
92+ virtual void GetDecoratorSettings(Window* window,
93+ BMessage& settings);
94+
95+ bool SATKeyPressed()
96+ { return fSATKeyPressed; }
97+
98+ SATWindow* GetSATWindow(Window* window);
99+ SATWindow* FindSATWindow(uint64 id);
100+
101+private:
102+ void _StartSAT();
103+ void _StopSAT();
104+ void _ActivateWindow(SATWindow* window);
105+ bool _HandleMessage(BPrivate::LinkReceiver& link,
106+ BPrivate::LinkSender& reply);
107+ SATGroup* _GetSATGroup(SATWindow* window);
108+
109+ Desktop* fDesktop;
110+
111+ bool fSATKeyPressed;
112+
113+ SATWindowMap fSATWindowMap;
114+ BObjectList<SATWindow> fGrouplessWindows;
115+
116+ SATWindow* fCurrentSATWindow;
117+};
118+
119+
120+class GroupIterator {
121+public:
122+ GroupIterator(StackAndTile* sat,
123+ Desktop* desktop);
124+
125+ SATGroup* CurrentGroup(void) const
126+ { return fCurrentGroup; };
127+ void SetCurrentGroup(SATGroup* group)
128+ { fCurrentGroup = group; };
129+
130+ void RewindToFront();
131+ SATGroup* NextGroup();
132+
133+private:
134+ StackAndTile* fStackAndTile;
135+ Desktop* fDesktop;
136+ Window* fCurrentWindow;
137+ SATGroup* fCurrentGroup;
138+};
139+
140+
141+class WindowIterator {
142+public:
143+ WindowIterator(SATGroup* group,
144+ bool reverseLayerOrder = false);
145+
146+ void Rewind();
147+ /*! Iterates over all areas in the group and return the windows in
148+ the areas. Within one area the windows are ordered by their layer
149+ position. If reverseLayerOrder is false the bottommost window comes
150+ first. */
151+ SATWindow* NextWindow();
152+
153+private:
154+ SATWindow* _ReverseNextWindow();
155+ void _ReverseRewind();
156+
157+ SATGroup* fGroup;
158+ bool fReverseLayerOrder;
159+
160+ WindowArea* fCurrentArea;
161+ int32 fAreaIndex;
162+ int32 fWindowIndex;
163+};
164+
165+
166+class SATSnappingBehaviour {
167+public:
168+ virtual ~SATSnappingBehaviour() {};
169+
170+ /*! Find all window candidates which possibly can join the group. Found
171+ candidates are marked here visual. */
172+ virtual bool FindSnappingCandidates(SATGroup* group) = 0;
173+ /*! Join all candidates found in FindSnappingCandidates to the group.
174+ Previously visually mark should be removed here. \return true if
175+ integration has been succeed. */
176+ virtual bool JoinCandidates() = 0;
177+ /*! Update the window tab values, solve the layout and move all windows in
178+ the group accordantly. */
179+ virtual void RemovedFromArea(WindowArea* area) {}
180+ virtual void WindowLookChanged(window_look look) {}
181+};
182+
183+
184+typedef BObjectList<SATSnappingBehaviour> SATSnappingBehaviourList;
185+
186+
187+#endif
+1100,
-0
1@@ -0,0 +1,1100 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * Ryan Leavengood, leavengood@gmail.com
10+ * Philippe Saint-Pierre, stpere@gmail.com
11+ * John Scipione, jscipione@gmail.com
12+ * Ingo Weinhold, ingo_weinhold@gmx.de
13+ * Clemens Zeidler, haiku@clemens-zeidler.de
14+ * Joseph Groover, looncraz@looncraz.net
15+ * Jacob Secunda, secundaja@gmail.com
16+ */
17+
18+
19+/*! Decorator made up of tabs */
20+
21+
22+#include "TabDecorator.h"
23+
24+#include <algorithm>
25+#include <cmath>
26+#include <new>
27+#include <stdio.h>
28+
29+#include <Autolock.h>
30+#include <Debug.h>
31+#include <GradientLinear.h>
32+#include <Rect.h>
33+#include <View.h>
34+
35+#include <WindowPrivate.h>
36+
37+#include "BitmapDrawingEngine.h"
38+#include "DesktopSettings.h"
39+#include "DrawingEngine.h"
40+#include "DrawState.h"
41+#include "FontManager.h"
42+#include "PatternHandler.h"
43+
44+
45+//#define DEBUG_DECORATOR
46+#ifdef DEBUG_DECORATOR
47+# define STRACE(x) printf x
48+#else
49+# define STRACE(x) ;
50+#endif
51+
52+
53+static bool
54+int_equal(float x, float y)
55+{
56+ return abs(x - y) <= 1;
57+}
58+
59+
60+static const float kBorderResizeLength = 22.0;
61+static const float kResizeKnobSize = 18.0;
62+
63+
64+// #pragma mark -
65+
66+
67+// TODO: get rid of DesktopSettings here, and introduce private accessor
68+// methods to the Decorator base class
69+TabDecorator::TabDecorator(DesktopSettings& settings, BRect frame,
70+ Desktop* desktop)
71+ :
72+ Decorator(settings, frame, desktop),
73+ fOldMovingTab(0, 0, -1, -1)
74+{
75+ STRACE(("TabDecorator:\n"));
76+ STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
77+ frame.left, frame.top, frame.right, frame.bottom));
78+
79+ // TODO: If the decorator was created with a frame too small, it should
80+ // resize itself!
81+}
82+
83+
84+TabDecorator::~TabDecorator()
85+{
86+ STRACE(("TabDecorator: ~TabDecorator()\n"));
87+}
88+
89+
90+// #pragma mark - Public methods
91+
92+
93+/*! \brief Updates the decorator in the rectangular area \a updateRect.
94+
95+ Updates all areas which intersect the frame and tab.
96+
97+ \param updateRect The rectangular area to update.
98+*/
99+void
100+TabDecorator::Draw(BRect updateRect)
101+{
102+ STRACE(("TabDecorator::Draw(BRect "
103+ "updateRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f))\n",
104+ updateRect.left, updateRect.top, updateRect.right, updateRect.bottom));
105+
106+ fDrawingEngine->SetDrawState(&fDrawState);
107+
108+ _DrawFrame(updateRect & fBorderRect);
109+
110+ if (IsOutlineResizing())
111+ _DrawOutlineFrame(updateRect & fOutlineBorderRect);
112+
113+ _DrawTabs(updateRect & fTitleBarRect);
114+}
115+
116+
117+//! Forces a complete decorator update
118+void
119+TabDecorator::Draw()
120+{
121+ STRACE(("TabDecorator: Draw()"));
122+
123+ fDrawingEngine->SetDrawState(&fDrawState);
124+
125+ _DrawFrame(fBorderRect);
126+
127+ if (IsOutlineResizing())
128+ _DrawOutlineFrame(fOutlineBorderRect);
129+
130+ _DrawTabs(fTitleBarRect);
131+}
132+
133+
134+Decorator::Region
135+TabDecorator::RegionAt(BPoint where, int32& tab) const
136+{
137+ // Let the base class version identify hits of the buttons and the tab.
138+ Region region = Decorator::RegionAt(where, tab);
139+ if (region != REGION_NONE)
140+ return region;
141+
142+ // check the resize corner
143+ if (fTopTab->look == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
144+ return REGION_RIGHT_BOTTOM_CORNER;
145+
146+ // hit-test the borders
147+ if (fLeftBorder.Contains(where))
148+ return REGION_LEFT_BORDER;
149+ if (fTopBorder.Contains(where))
150+ return REGION_TOP_BORDER;
151+
152+ // Part of the bottom and right borders may be a resize-region, so we have
153+ // to check explicitly, if it has been it.
154+ if (fRightBorder.Contains(where))
155+ region = REGION_RIGHT_BORDER;
156+ else if (fBottomBorder.Contains(where))
157+ region = REGION_BOTTOM_BORDER;
158+ else
159+ return REGION_NONE;
160+
161+ // check resize area
162+ if ((fTopTab->flags & B_NOT_RESIZABLE) == 0
163+ && (fTopTab->look == B_TITLED_WINDOW_LOOK
164+ || fTopTab->look == B_FLOATING_WINDOW_LOOK
165+ || fTopTab->look == B_MODAL_WINDOW_LOOK
166+ || fTopTab->look == kLeftTitledWindowLook)) {
167+ BRect resizeRect(BPoint(fBottomBorder.right - fBorderResizeLength,
168+ fBottomBorder.bottom - fBorderResizeLength),
169+ fBottomBorder.RightBottom());
170+ if (resizeRect.Contains(where))
171+ return REGION_RIGHT_BOTTOM_CORNER;
172+ }
173+
174+ return region;
175+}
176+
177+
178+bool
179+TabDecorator::SetRegionHighlight(Region region, uint8 highlight,
180+ BRegion* dirty, int32 tabIndex)
181+{
182+ Decorator::Tab* tab
183+ = static_cast<Decorator::Tab*>(_TabAt(tabIndex));
184+ if (tab != NULL) {
185+ tab->isHighlighted = highlight != 0;
186+ // Invalidate the bitmap caches for the close/zoom button, when the
187+ // highlight changes.
188+ switch (region) {
189+ case REGION_CLOSE_BUTTON:
190+ if (highlight != RegionHighlight(region))
191+ memset(&tab->closeBitmaps, 0, sizeof(tab->closeBitmaps));
192+ break;
193+ case REGION_ZOOM_BUTTON:
194+ if (highlight != RegionHighlight(region))
195+ memset(&tab->zoomBitmaps, 0, sizeof(tab->zoomBitmaps));
196+ break;
197+ default:
198+ break;
199+ }
200+ }
201+
202+ return Decorator::SetRegionHighlight(region, highlight, dirty, tabIndex);
203+}
204+
205+
206+void
207+TabDecorator::UpdateColors(DesktopSettings& settings)
208+{
209+ // Desktop is write locked, so be quick about it.
210+ fFocusFrameColor = settings.UIColor(B_WINDOW_BORDER_COLOR);
211+ fFocusTabColor = settings.UIColor(B_WINDOW_TAB_COLOR);
212+ fFocusTabColorLight = tint_color(fFocusTabColor,
213+ (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
214+ fFocusTabColorBevel = tint_color(fFocusTabColor, B_LIGHTEN_2_TINT);
215+ fFocusTabColorShadow = tint_color(fFocusTabColor,
216+ (B_DARKEN_1_TINT + B_NO_TINT) / 2);
217+ fFocusTextColor = settings.UIColor(B_WINDOW_TEXT_COLOR);
218+
219+ fNonFocusFrameColor = settings.UIColor(B_WINDOW_INACTIVE_BORDER_COLOR);
220+ fNonFocusTabColor = settings.UIColor(B_WINDOW_INACTIVE_TAB_COLOR);
221+ fNonFocusTabColorLight = tint_color(fNonFocusTabColor,
222+ (B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
223+ fNonFocusTabColorBevel = tint_color(fNonFocusTabColor, B_LIGHTEN_2_TINT);
224+ fNonFocusTabColorShadow = tint_color(fNonFocusTabColor,
225+ (B_DARKEN_1_TINT + B_NO_TINT) / 2);
226+ fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
227+}
228+
229+
230+void
231+TabDecorator::_DoLayout()
232+{
233+ STRACE(("TabDecorator: Do Layout\n"));
234+ // Here we determine the size of every rectangle that we use
235+ // internally when we are given the size of the client rectangle.
236+
237+ bool hasTab = false;
238+
239+ // TODO: Put this computation somewhere more central!
240+ const float scaleFactor = max_c(fDrawState.Font().Size() / 12.0f, 1.0f);
241+
242+ switch ((int)fTopTab->look) {
243+ case B_MODAL_WINDOW_LOOK:
244+ fBorderWidth = 5;
245+ break;
246+
247+ case B_TITLED_WINDOW_LOOK:
248+ case B_DOCUMENT_WINDOW_LOOK:
249+ hasTab = true;
250+ fBorderWidth = 5;
251+ break;
252+ case B_FLOATING_WINDOW_LOOK:
253+ case kLeftTitledWindowLook:
254+ hasTab = true;
255+ fBorderWidth = 3;
256+ break;
257+
258+ case B_BORDERED_WINDOW_LOOK:
259+ fBorderWidth = 1;
260+ break;
261+
262+ default:
263+ fBorderWidth = 0;
264+ }
265+
266+ fBorderWidth = int32(fBorderWidth * scaleFactor);
267+ fResizeKnobSize = kResizeKnobSize * scaleFactor;
268+ fBorderResizeLength = kBorderResizeLength * scaleFactor;
269+
270+ // calculate left/top/right/bottom borders
271+ if (fBorderWidth > 0) {
272+ // NOTE: no overlapping, the left and right border rects
273+ // don't include the corners!
274+ fLeftBorder.Set(fFrame.left - fBorderWidth, fFrame.top,
275+ fFrame.left - 1, fFrame.bottom);
276+
277+ fRightBorder.Set(fFrame.right + 1, fFrame.top ,
278+ fFrame.right + fBorderWidth, fFrame.bottom);
279+
280+ fTopBorder.Set(fFrame.left - fBorderWidth, fFrame.top - fBorderWidth,
281+ fFrame.right + fBorderWidth, fFrame.top - 1);
282+
283+ fBottomBorder.Set(fFrame.left - fBorderWidth, fFrame.bottom + 1,
284+ fFrame.right + fBorderWidth, fFrame.bottom + fBorderWidth);
285+ } else {
286+ // no border
287+ fLeftBorder.Set(0.0, 0.0, -1.0, -1.0);
288+ fRightBorder.Set(0.0, 0.0, -1.0, -1.0);
289+ fTopBorder.Set(0.0, 0.0, -1.0, -1.0);
290+ fBottomBorder.Set(0.0, 0.0, -1.0, -1.0);
291+ }
292+
293+ fBorderRect = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
294+
295+ // calculate resize rect
296+ if (fBorderWidth > 1) {
297+ fResizeRect.Set(fBottomBorder.right - fResizeKnobSize,
298+ fBottomBorder.bottom - fResizeKnobSize, fBottomBorder.right,
299+ fBottomBorder.bottom);
300+ } else {
301+ // no border or one pixel border (menus and such)
302+ fResizeRect.Set(0, 0, -1, -1);
303+ }
304+
305+ if (hasTab) {
306+ _DoTabLayout();
307+ return;
308+ } else {
309+ // no tab
310+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
311+ Decorator::Tab* tab = fTabList.ItemAt(i);
312+ tab->tabRect.Set(0.0, 0.0, -1.0, -1.0);
313+ }
314+ fTabsRegion.MakeEmpty();
315+ fTitleBarRect.Set(0.0, 0.0, -1.0, -1.0);
316+ }
317+}
318+
319+
320+void
321+TabDecorator::_DoOutlineLayout()
322+{
323+ fOutlineBorderWidth = 1;
324+
325+ // calculate left/top/right/bottom outline borders
326+ // NOTE: no overlapping, the left and right border rects
327+ // don't include the corners!
328+ fLeftOutlineBorder.Set(fFrame.left - fOutlineBorderWidth, fFrame.top,
329+ fFrame.left - 1, fFrame.bottom);
330+
331+ fRightOutlineBorder.Set(fFrame.right + 1, fFrame.top ,
332+ fFrame.right + fOutlineBorderWidth, fFrame.bottom);
333+
334+ fTopOutlineBorder.Set(fFrame.left - fOutlineBorderWidth,
335+ fFrame.top - fOutlineBorderWidth,
336+ fFrame.right + fOutlineBorderWidth, fFrame.top - 1);
337+
338+ fBottomOutlineBorder.Set(fFrame.left - fOutlineBorderWidth,
339+ fFrame.bottom + 1,
340+ fFrame.right + fOutlineBorderWidth,
341+ fFrame.bottom + fOutlineBorderWidth);
342+
343+ fOutlineBorderRect = BRect(fTopOutlineBorder.LeftTop(),
344+ fBottomOutlineBorder.RightBottom());
345+}
346+
347+
348+void
349+TabDecorator::_DoTabLayout()
350+{
351+ float tabOffset = 0;
352+ if (fTabList.CountItems() == 1) {
353+ float tabSize;
354+ tabOffset = _SingleTabOffsetAndSize(tabSize);
355+ }
356+
357+ float sumTabWidth = 0;
358+ // calculate our tab rect
359+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
360+ Decorator::Tab* tab = _TabAt(i);
361+
362+ BRect& tabRect = tab->tabRect;
363+ // distance from one item of the tab bar to another.
364+ // In this case the text and close/zoom rects
365+ tab->textOffset = _DefaultTextOffset();
366+
367+ font_height fontHeight;
368+ fDrawState.Font().GetHeight(fontHeight);
369+
370+ if (tab->look != kLeftTitledWindowLook) {
371+ const float spacing = fBorderWidth * 1.4f;
372+ tabRect.Set(fFrame.left - fBorderWidth,
373+ fFrame.top - fBorderWidth
374+ - ceilf(fontHeight.ascent + fontHeight.descent + spacing),
375+ ((fFrame.right - fFrame.left) < (spacing * 5) ?
376+ fFrame.left + (spacing * 5) : fFrame.right) + fBorderWidth,
377+ fFrame.top - fBorderWidth);
378+ } else {
379+ tabRect.Set(fFrame.left - fBorderWidth
380+ - ceilf(fontHeight.ascent + fontHeight.descent + fBorderWidth),
381+ fFrame.top - fBorderWidth, fFrame.left - fBorderWidth,
382+ fFrame.bottom + fBorderWidth);
383+ }
384+
385+ // format tab rect for a floating window - make the rect smaller
386+ if (tab->look == B_FLOATING_WINDOW_LOOK) {
387+ tabRect.InsetBy(0, 2);
388+ tabRect.OffsetBy(0, 2);
389+ }
390+
391+ float offset;
392+ float size;
393+ float inset;
394+ _GetButtonSizeAndOffset(tabRect, &offset, &size, &inset);
395+
396+ // tab->minTabSize contains just the room for the buttons
397+ tab->minTabSize = inset * 2 + tab->textOffset;
398+ if ((tab->flags & B_NOT_CLOSABLE) == 0)
399+ tab->minTabSize += offset + size;
400+ if ((tab->flags & B_NOT_ZOOMABLE) == 0)
401+ tab->minTabSize += offset + size;
402+
403+ // tab->maxTabSize contains tab->minTabSize + the width required for the
404+ // title
405+ tab->maxTabSize = fDrawingEngine
406+ ? ceilf(fDrawingEngine->StringWidth(Title(tab), strlen(Title(tab)),
407+ fDrawState.Font())) : 0.0;
408+ if (tab->maxTabSize > 0.0)
409+ tab->maxTabSize += tab->textOffset;
410+ tab->maxTabSize += tab->minTabSize;
411+
412+ float tabSize = (tab->look != kLeftTitledWindowLook
413+ ? fFrame.Width() : fFrame.Height()) + fBorderWidth * 2;
414+ if (tabSize < tab->minTabSize)
415+ tabSize = tab->minTabSize;
416+ if (tabSize > tab->maxTabSize)
417+ tabSize = tab->maxTabSize;
418+
419+ // layout buttons and truncate text
420+ if (tab->look != kLeftTitledWindowLook)
421+ tabRect.right = tabRect.left + tabSize;
422+ else
423+ tabRect.bottom = tabRect.top + tabSize;
424+
425+ // make sure fTabOffset is within limits and apply it to
426+ // the tabRect
427+ tab->tabOffset = (uint32)tabOffset;
428+ if (tab->tabLocation != 0.0 && fTabList.CountItems() == 1
429+ && tab->tabOffset > (fRightBorder.right - fLeftBorder.left
430+ - tabRect.Width())) {
431+ tab->tabOffset = uint32(fRightBorder.right - fLeftBorder.left
432+ - tabRect.Width());
433+ }
434+ tabRect.OffsetBy(tab->tabOffset, 0);
435+ tabOffset += tabRect.Width();
436+
437+ sumTabWidth += tabRect.Width();
438+ }
439+
440+ float windowWidth = fFrame.Width() + 2 * fBorderWidth;
441+ if (CountTabs() > 1 && sumTabWidth > windowWidth)
442+ _DistributeTabSize(sumTabWidth - windowWidth);
443+
444+ // finally, layout the buttons and text within the tab rect
445+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
446+ Decorator::Tab* tab = fTabList.ItemAt(i);
447+
448+ if (i == 0)
449+ fTitleBarRect = tab->tabRect;
450+ else
451+ fTitleBarRect = fTitleBarRect | tab->tabRect;
452+
453+ _LayoutTabItems(tab, tab->tabRect);
454+ }
455+
456+ fTabsRegion = fTitleBarRect;
457+}
458+
459+
460+void
461+TabDecorator::_DistributeTabSize(float delta)
462+{
463+ int32 tabCount = fTabList.CountItems();
464+ ASSERT(tabCount > 1);
465+
466+ float maxTabSize = 0;
467+ float secMaxTabSize = 0;
468+ int32 nTabsWithMaxSize = 0;
469+ for (int32 i = 0; i < tabCount; i++) {
470+ Decorator::Tab* tab = fTabList.ItemAt(i);
471+ if (tab == NULL)
472+ continue;
473+
474+ float tabWidth = tab->tabRect.Width();
475+ if (int_equal(maxTabSize, tabWidth)) {
476+ nTabsWithMaxSize++;
477+ continue;
478+ }
479+ if (maxTabSize < tabWidth) {
480+ secMaxTabSize = maxTabSize;
481+ maxTabSize = tabWidth;
482+ nTabsWithMaxSize = 1;
483+ } else if (secMaxTabSize <= tabWidth)
484+ secMaxTabSize = tabWidth;
485+ }
486+
487+ float minus = ceilf(std::min(maxTabSize - secMaxTabSize, delta));
488+ if (minus < 1.0)
489+ return;
490+ delta -= minus;
491+ minus /= nTabsWithMaxSize;
492+
493+ Decorator::Tab* previousTab = NULL;
494+ for (int32 i = 0; i < tabCount; i++) {
495+ Decorator::Tab* tab = fTabList.ItemAt(i);
496+ if (tab == NULL)
497+ continue;
498+
499+ if (int_equal(maxTabSize, tab->tabRect.Width()))
500+ tab->tabRect.right -= minus;
501+
502+ if (previousTab != NULL) {
503+ float offsetX = previousTab->tabRect.right - tab->tabRect.left;
504+ tab->tabRect.OffsetBy(offsetX, 0);
505+ }
506+
507+ previousTab = tab;
508+ }
509+
510+ if (delta > 0) {
511+ _DistributeTabSize(delta);
512+ return;
513+ }
514+
515+ // done
516+ if (previousTab != NULL)
517+ previousTab->tabRect.right = floorf(fFrame.right + fBorderWidth);
518+
519+ for (int32 i = 0; i < tabCount; i++) {
520+ Decorator::Tab* tab = fTabList.ItemAt(i);
521+ if (tab == NULL)
522+ continue;
523+
524+ tab->tabOffset = uint32(tab->tabRect.left - fLeftBorder.left);
525+ }
526+}
527+
528+
529+void
530+TabDecorator::_DrawOutlineFrame(BRect rect)
531+{
532+ drawing_mode oldMode;
533+
534+ fDrawingEngine->SetDrawingMode(B_OP_ALPHA, oldMode);
535+ fDrawingEngine->SetPattern(B_MIXED_COLORS);
536+ fDrawingEngine->StrokeRect(rect);
537+
538+ fDrawingEngine->SetDrawingMode(oldMode);
539+}
540+
541+
542+void
543+TabDecorator::_SetTitle(Decorator::Tab* tab, const char* string,
544+ BRegion* updateRegion)
545+{
546+ // TODO: we could be much smarter about the update region
547+
548+ BRect rect = TabRect((int32) 0) | TabRect(CountTabs() - 1);
549+ // Get a rect of all the tabs
550+
551+ _DoLayout();
552+ _DoOutlineLayout();
553+
554+ if (updateRegion == NULL)
555+ return;
556+
557+ rect = rect | TabRect(CountTabs() - 1);
558+ // Update the rect to guarantee it updates all the tabs
559+
560+ rect.bottom++;
561+ // the border will look differently when the title is adjacent
562+
563+ updateRegion->Include(rect);
564+}
565+
566+
567+void
568+TabDecorator::_MoveBy(BPoint offset)
569+{
570+ STRACE(("TabDecorator: Move By (%.1f, %.1f)\n", offset.x, offset.y));
571+
572+ // Move all internal rectangles the appropriate amount
573+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
574+ Decorator::Tab* tab = fTabList.ItemAt(i);
575+ tab->zoomRect.OffsetBy(offset);
576+ tab->closeRect.OffsetBy(offset);
577+ tab->tabRect.OffsetBy(offset);
578+ }
579+
580+ fFrame.OffsetBy(offset);
581+ fTitleBarRect.OffsetBy(offset);
582+ fTabsRegion.OffsetBy(offset);
583+ fResizeRect.OffsetBy(offset);
584+ fBorderRect.OffsetBy(offset);
585+
586+ fLeftBorder.OffsetBy(offset);
587+ fRightBorder.OffsetBy(offset);
588+ fTopBorder.OffsetBy(offset);
589+ fBottomBorder.OffsetBy(offset);
590+}
591+
592+
593+void
594+TabDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
595+{
596+ STRACE(("TabDecorator: Resize By (%.1f, %.1f)\n", offset.x, offset.y));
597+
598+ // Move all internal rectangles the appropriate amount
599+ fFrame.right += offset.x;
600+ fFrame.bottom += offset.y;
601+
602+ // Handle invalidation of resize rect
603+ if (dirty != NULL && !(fTopTab->flags & B_NOT_RESIZABLE)) {
604+ BRect realResizeRect;
605+ switch ((int)fTopTab->look) {
606+ case B_DOCUMENT_WINDOW_LOOK:
607+ realResizeRect = fResizeRect;
608+ // Resize rect at old location
609+ dirty->Include(realResizeRect);
610+ realResizeRect.OffsetBy(offset);
611+ // Resize rect at new location
612+ dirty->Include(realResizeRect);
613+ break;
614+
615+ case B_TITLED_WINDOW_LOOK:
616+ case B_FLOATING_WINDOW_LOOK:
617+ case B_MODAL_WINDOW_LOOK:
618+ case kLeftTitledWindowLook:
619+ // The bottom border resize line
620+ realResizeRect.Set(fRightBorder.right - fBorderResizeLength,
621+ fBottomBorder.top,
622+ fRightBorder.right - fBorderResizeLength,
623+ fBottomBorder.bottom - 1);
624+ // Old location
625+ dirty->Include(realResizeRect);
626+ realResizeRect.OffsetBy(offset);
627+ // New location
628+ dirty->Include(realResizeRect);
629+
630+ // The right border resize line
631+ realResizeRect.Set(fRightBorder.left,
632+ fBottomBorder.bottom - fBorderResizeLength,
633+ fRightBorder.right - 1,
634+ fBottomBorder.bottom - fBorderResizeLength);
635+ // Old location
636+ dirty->Include(realResizeRect);
637+ realResizeRect.OffsetBy(offset);
638+ // New location
639+ dirty->Include(realResizeRect);
640+ break;
641+
642+ default:
643+ break;
644+ }
645+ }
646+
647+ fResizeRect.OffsetBy(offset);
648+
649+ fBorderRect.right += offset.x;
650+ fBorderRect.bottom += offset.y;
651+
652+ fLeftBorder.bottom += offset.y;
653+ fTopBorder.right += offset.x;
654+
655+ fRightBorder.OffsetBy(offset.x, 0.0);
656+ fRightBorder.bottom += offset.y;
657+
658+ fBottomBorder.OffsetBy(0.0, offset.y);
659+ fBottomBorder.right += offset.x;
660+
661+ if (dirty) {
662+ if (offset.x > 0.0) {
663+ BRect t(fRightBorder.left - offset.x, fTopBorder.top,
664+ fRightBorder.right, fTopBorder.bottom);
665+ dirty->Include(t);
666+ t.Set(fRightBorder.left - offset.x, fBottomBorder.top,
667+ fRightBorder.right, fBottomBorder.bottom);
668+ dirty->Include(t);
669+ dirty->Include(fRightBorder);
670+ } else if (offset.x < 0.0) {
671+ dirty->Include(BRect(fRightBorder.left, fTopBorder.top,
672+ fRightBorder.right, fBottomBorder.bottom));
673+ }
674+ if (offset.y > 0.0) {
675+ BRect t(fLeftBorder.left, fLeftBorder.bottom - offset.y,
676+ fLeftBorder.right, fLeftBorder.bottom);
677+ dirty->Include(t);
678+ t.Set(fRightBorder.left, fRightBorder.bottom - offset.y,
679+ fRightBorder.right, fRightBorder.bottom);
680+ dirty->Include(t);
681+ dirty->Include(fBottomBorder);
682+ } else if (offset.y < 0.0) {
683+ dirty->Include(fBottomBorder);
684+ }
685+ }
686+
687+ // resize tab and layout tab items
688+ if (fTitleBarRect.IsValid()) {
689+ if (fTabList.CountItems() > 1) {
690+ _DoTabLayout();
691+ if (dirty != NULL)
692+ dirty->Include(fTitleBarRect);
693+ return;
694+ }
695+
696+ Decorator::Tab* tab = _TabAt(0);
697+ BRect& tabRect = tab->tabRect;
698+ BRect oldTabRect(tabRect);
699+
700+ float tabSize;
701+ float tabOffset = _SingleTabOffsetAndSize(tabSize);
702+
703+ float delta = tabOffset - tab->tabOffset;
704+ tab->tabOffset = (uint32)tabOffset;
705+ if (fTopTab->look != kLeftTitledWindowLook)
706+ tabRect.OffsetBy(delta, 0.0);
707+ else
708+ tabRect.OffsetBy(0.0, delta);
709+
710+ if (tabSize < tab->minTabSize)
711+ tabSize = tab->minTabSize;
712+ if (tabSize > tab->maxTabSize)
713+ tabSize = tab->maxTabSize;
714+
715+ if (fTopTab->look != kLeftTitledWindowLook
716+ && tabSize != tabRect.Width()) {
717+ tabRect.right = tabRect.left + tabSize;
718+ } else if (fTopTab->look == kLeftTitledWindowLook
719+ && tabSize != tabRect.Height()) {
720+ tabRect.bottom = tabRect.top + tabSize;
721+ }
722+
723+ if (oldTabRect != tabRect) {
724+ _LayoutTabItems(tab, tabRect);
725+
726+ if (dirty) {
727+ // NOTE: the tab rect becoming smaller only would
728+ // handled be the Desktop anyways, so it is sufficient
729+ // to include it into the dirty region in it's
730+ // final state
731+ BRect redraw(tabRect);
732+ if (delta != 0.0) {
733+ redraw = redraw | oldTabRect;
734+ if (fTopTab->look != kLeftTitledWindowLook)
735+ redraw.bottom++;
736+ else
737+ redraw.right++;
738+ }
739+ dirty->Include(redraw);
740+ }
741+ }
742+ fTitleBarRect = tabRect;
743+ fTabsRegion = fTitleBarRect;
744+ }
745+}
746+
747+
748+void
749+TabDecorator::_SetFocus(Decorator::Tab* tab)
750+{
751+ Decorator::Tab* decoratorTab = static_cast<Decorator::Tab*>(tab);
752+
753+ decoratorTab->buttonFocus = IsFocus(tab)
754+ || ((decoratorTab->look == B_FLOATING_WINDOW_LOOK
755+ || decoratorTab->look == kLeftTitledWindowLook)
756+ && (decoratorTab->flags & B_AVOID_FOCUS) != 0);
757+ if (CountTabs() > 1)
758+ _LayoutTabItems(decoratorTab, decoratorTab->tabRect);
759+}
760+
761+
762+bool
763+TabDecorator::_SetTabLocation(Decorator::Tab* _tab, float location,
764+ bool isShifting, BRegion* updateRegion)
765+{
766+ STRACE(("TabDecorator: Set Tab Location(%.1f)\n", location));
767+
768+ if (CountTabs() > 1) {
769+ if (isShifting == false) {
770+ _DoTabLayout();
771+ if (updateRegion != NULL)
772+ updateRegion->Include(fTitleBarRect);
773+
774+ fOldMovingTab = BRect(0, 0, -1, -1);
775+ return true;
776+ } else {
777+ if (fOldMovingTab.IsValid() == false)
778+ fOldMovingTab = _tab->tabRect;
779+ }
780+ }
781+
782+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
783+ BRect& tabRect = tab->tabRect;
784+ if (tabRect.IsValid() == false)
785+ return false;
786+
787+ if (location < 0)
788+ location = 0;
789+
790+ float maxLocation
791+ = fRightBorder.right - fLeftBorder.left - tabRect.Width();
792+ if (CountTabs() > 1)
793+ maxLocation = fTitleBarRect.right - fLeftBorder.left - tabRect.Width();
794+
795+ if (location > maxLocation)
796+ location = maxLocation;
797+
798+ float delta = floor(location - tab->tabOffset);
799+ if (delta == 0.0)
800+ return false;
801+
802+ // redraw old rect (1 pixel on the border must also be updated)
803+ BRect rect(tabRect);
804+ rect.bottom++;
805+ if (updateRegion != NULL)
806+ updateRegion->Include(rect);
807+
808+ tabRect.OffsetBy(delta, 0);
809+ tab->tabOffset = (int32)location;
810+ _LayoutTabItems(_tab, tabRect);
811+ tab->tabLocation = maxLocation > 0.0 ? tab->tabOffset / maxLocation : 0.0;
812+
813+ if (fTabList.CountItems() == 1)
814+ fTitleBarRect = tabRect;
815+
816+ _CalculateTabsRegion();
817+
818+ // redraw new rect as well
819+ rect = tabRect;
820+ rect.bottom++;
821+ if (updateRegion != NULL)
822+ updateRegion->Include(rect);
823+
824+ return true;
825+}
826+
827+
828+bool
829+TabDecorator::_SetSettings(const BMessage& settings, BRegion* updateRegion)
830+{
831+ float tabLocation;
832+ bool modified = false;
833+ for (int32 i = 0; i < fTabList.CountItems(); i++) {
834+ if (settings.FindFloat("tab location", i, &tabLocation) != B_OK)
835+ return false;
836+ modified |= SetTabLocation(i, tabLocation, updateRegion);
837+ }
838+ return modified;
839+}
840+
841+
842+bool
843+TabDecorator::_AddTab(DesktopSettings& settings, int32 index,
844+ BRegion* updateRegion)
845+{
846+ _UpdateFont(settings);
847+
848+ _DoLayout();
849+ _DoOutlineLayout();
850+
851+ if (updateRegion != NULL)
852+ updateRegion->Include(fTitleBarRect);
853+ return true;
854+}
855+
856+
857+bool
858+TabDecorator::_RemoveTab(int32 index, BRegion* updateRegion)
859+{
860+ BRect oldRect = TabRect(index) | TabRect(CountTabs() - 1);
861+ // Get a rect of all the tabs to the right - they will all be moved
862+
863+ _DoLayout();
864+ _DoOutlineLayout();
865+
866+ if (updateRegion != NULL) {
867+ updateRegion->Include(oldRect);
868+ updateRegion->Include(fTitleBarRect);
869+ }
870+ return true;
871+}
872+
873+
874+bool
875+TabDecorator::_MoveTab(int32 from, int32 to, bool isMoving,
876+ BRegion* updateRegion)
877+{
878+ Decorator::Tab* toTab = _TabAt(to);
879+ if (toTab == NULL)
880+ return false;
881+
882+ if (from < to) {
883+ fOldMovingTab.OffsetBy(toTab->tabRect.Width(), 0);
884+ toTab->tabRect.OffsetBy(-fOldMovingTab.Width(), 0);
885+ } else {
886+ fOldMovingTab.OffsetBy(-toTab->tabRect.Width(), 0);
887+ toTab->tabRect.OffsetBy(fOldMovingTab.Width(), 0);
888+ }
889+
890+ toTab->tabOffset = uint32(toTab->tabRect.left - fLeftBorder.left);
891+ _LayoutTabItems(toTab, toTab->tabRect);
892+
893+ _CalculateTabsRegion();
894+
895+ if (updateRegion != NULL)
896+ updateRegion->Include(fTitleBarRect);
897+ return true;
898+}
899+
900+
901+void
902+TabDecorator::_GetFootprint(BRegion *region)
903+{
904+ STRACE(("TabDecorator: GetFootprint\n"));
905+
906+ // This function calculates the decorator's footprint in coordinates
907+ // relative to the view. This is most often used to set a Window
908+ // object's visible region.
909+
910+ if (region == NULL)
911+ return;
912+
913+ if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
914+ return;
915+
916+ region->Include(fTopBorder);
917+ region->Include(fLeftBorder);
918+ region->Include(fRightBorder);
919+ region->Include(fBottomBorder);
920+
921+ if (fTopTab->look == B_BORDERED_WINDOW_LOOK)
922+ return;
923+
924+ region->Include(&fTabsRegion);
925+
926+ if (fTopTab->look == B_DOCUMENT_WINDOW_LOOK) {
927+ // include the rectangular resize knob on the bottom right
928+ float knobSize = fResizeKnobSize - fBorderWidth;
929+ region->Include(BRect(fFrame.right - knobSize, fFrame.bottom - knobSize,
930+ fFrame.right, fFrame.bottom));
931+ }
932+}
933+
934+
935+void
936+TabDecorator::_DrawButtons(Decorator::Tab* tab, const BRect& invalid)
937+{
938+ STRACE(("TabDecorator: _DrawButtons\n"));
939+
940+ // Draw the buttons if we're supposed to
941+ if (!(tab->flags & B_NOT_CLOSABLE) && invalid.Intersects(tab->closeRect))
942+ _DrawClose(tab, false, tab->closeRect);
943+ if (!(tab->flags & B_NOT_ZOOMABLE) && invalid.Intersects(tab->zoomRect))
944+ _DrawZoom(tab, false, tab->zoomRect);
945+}
946+
947+
948+void
949+TabDecorator::_UpdateFont(DesktopSettings& settings)
950+{
951+ ServerFont font;
952+ if (fTopTab->look == B_FLOATING_WINDOW_LOOK
953+ || fTopTab->look == kLeftTitledWindowLook) {
954+ settings.GetDefaultPlainFont(font);
955+ if (fTopTab->look == kLeftTitledWindowLook)
956+ font.SetRotation(90.0f);
957+ } else
958+ settings.GetDefaultBoldFont(font);
959+
960+ font.SetFlags(B_FORCE_ANTIALIASING);
961+ font.SetSpacing(B_STRING_SPACING);
962+ fDrawState.SetFont(font);
963+}
964+
965+
966+void
967+TabDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* _offset,
968+ float* _size, float* _inset) const
969+{
970+ float tabSize = fTopTab->look == kLeftTitledWindowLook ?
971+ tabRect.Width() : tabRect.Height();
972+
973+ bool smallTab = fTopTab->look == B_FLOATING_WINDOW_LOOK
974+ || fTopTab->look == kLeftTitledWindowLook;
975+
976+ *_offset = smallTab ? floorf(fDrawState.Font().Size() / 2.6)
977+ : floorf(fDrawState.Font().Size() / 2.3);
978+ *_inset = smallTab ? floorf(fDrawState.Font().Size() / 5.0)
979+ : floorf(fDrawState.Font().Size() / 6.0);
980+
981+ // "+ 2" so that the rects are centered within the solid area
982+ // (without the 2 pixels for the top border)
983+ *_size = tabSize - 2 * *_offset + *_inset;
984+}
985+
986+
987+void
988+TabDecorator::_LayoutTabItems(Decorator::Tab* _tab, const BRect& tabRect)
989+{
990+ Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
991+
992+ float offset;
993+ float size;
994+ float inset;
995+ _GetButtonSizeAndOffset(tabRect, &offset, &size, &inset);
996+
997+ // default textOffset
998+ tab->textOffset = _DefaultTextOffset();
999+
1000+ BRect& closeRect = tab->closeRect;
1001+ BRect& zoomRect = tab->zoomRect;
1002+
1003+ // calulate close rect based on the tab rectangle
1004+ if (tab->look != kLeftTitledWindowLook) {
1005+ closeRect.Set(tabRect.left + offset, tabRect.top + offset,
1006+ tabRect.left + offset + size, tabRect.top + offset + size);
1007+
1008+ zoomRect.Set(tabRect.right - offset - size, tabRect.top + offset,
1009+ tabRect.right - offset, tabRect.top + offset + size);
1010+
1011+ // hidden buttons have no width
1012+ if ((tab->flags & B_NOT_CLOSABLE) != 0)
1013+ closeRect.right = closeRect.left - offset;
1014+ if ((tab->flags & B_NOT_ZOOMABLE) != 0)
1015+ zoomRect.left = zoomRect.right + offset;
1016+ } else {
1017+ closeRect.Set(tabRect.left + offset, tabRect.top + offset,
1018+ tabRect.left + offset + size, tabRect.top + offset + size);
1019+
1020+ zoomRect.Set(tabRect.left + offset, tabRect.bottom - offset - size,
1021+ tabRect.left + size + offset, tabRect.bottom - offset);
1022+
1023+ // hidden buttons have no height
1024+ if ((tab->flags & B_NOT_CLOSABLE) != 0)
1025+ closeRect.bottom = closeRect.top - offset;
1026+ if ((tab->flags & B_NOT_ZOOMABLE) != 0)
1027+ zoomRect.top = zoomRect.bottom + offset;
1028+ }
1029+
1030+ // calculate room for title
1031+ // TODO: the +2 is there because the title often appeared
1032+ // truncated for no apparent reason - OTOH the title does
1033+ // also not appear perfectly in the middle
1034+ if (tab->look != kLeftTitledWindowLook)
1035+ size = (zoomRect.left - closeRect.right) - tab->textOffset * 2 + inset;
1036+ else
1037+ size = (zoomRect.top - closeRect.bottom) - tab->textOffset * 2 + inset;
1038+
1039+ bool stackMode = fTabList.CountItems() > 1;
1040+ if (stackMode && IsFocus(tab) == false) {
1041+ zoomRect.Set(0, 0, 0, 0);
1042+ size = (tab->tabRect.right - closeRect.right) - tab->textOffset * 2
1043+ + inset;
1044+ }
1045+ uint8 truncateMode = B_TRUNCATE_MIDDLE;
1046+ if (stackMode) {
1047+ if (tab->tabRect.Width() < 100)
1048+ truncateMode = B_TRUNCATE_END;
1049+ float titleWidth = fDrawState.Font().StringWidth(Title(tab),
1050+ BString(Title(tab)).Length());
1051+ if (size < titleWidth) {
1052+ float oldTextOffset = tab->textOffset;
1053+ tab->textOffset -= (titleWidth - size) / 2;
1054+ const float kMinTextOffset = 5.;
1055+ if (tab->textOffset < kMinTextOffset)
1056+ tab->textOffset = kMinTextOffset;
1057+ size += oldTextOffset * 2;
1058+ size -= tab->textOffset * 2;
1059+ }
1060+ }
1061+ tab->truncatedTitle = Title(tab);
1062+ fDrawState.Font().TruncateString(&tab->truncatedTitle, truncateMode, size);
1063+ tab->truncatedTitleLength = tab->truncatedTitle.Length();
1064+}
1065+
1066+
1067+float
1068+TabDecorator::_DefaultTextOffset() const
1069+{
1070+ if (fTopTab->look == B_FLOATING_WINDOW_LOOK
1071+ || fTopTab->look == kLeftTitledWindowLook)
1072+ return int32(fBorderWidth * 3.4f);
1073+ return int32(fBorderWidth * 3.6f);
1074+}
1075+
1076+
1077+float
1078+TabDecorator::_SingleTabOffsetAndSize(float& tabSize)
1079+{
1080+ float maxLocation;
1081+ if (fTopTab->look != kLeftTitledWindowLook) {
1082+ tabSize = fRightBorder.right - fLeftBorder.left;
1083+ } else {
1084+ tabSize = fBottomBorder.bottom - fTopBorder.top;
1085+ }
1086+ Decorator::Tab* tab = _TabAt(0);
1087+ maxLocation = tabSize - tab->maxTabSize;
1088+ if (maxLocation < 0)
1089+ maxLocation = 0;
1090+
1091+ return floorf(tab->tabLocation * maxLocation);
1092+}
1093+
1094+
1095+void
1096+TabDecorator::_CalculateTabsRegion()
1097+{
1098+ fTabsRegion.MakeEmpty();
1099+ for (int32 i = 0; i < fTabList.CountItems(); i++)
1100+ fTabsRegion.Include(fTabList.ItemAt(i)->tabRect);
1101+}
+160,
-0
1@@ -0,0 +1,160 @@
2+/*
3+ * Copyright 2001-2020 Haiku, Inc.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Stephan Aßmus, superstippi@gmx.de
8+ * DarkWyrm, bpmagic@columbus.rr.com
9+ * Ryan Leavengood, leavengood@gmail.com
10+ * Philippe Saint-Pierre, stpere@gmail.com
11+ * John Scipione, jscipione@gmail.com
12+ * Ingo Weinhold, ingo_weinhold@gmx.de
13+ * Clemens Zeidler, haiku@clemens-zeidler.de
14+ * Joseph Groover, looncraz@looncraz.net
15+ * Jacob Secunda, secundja@gmail.com
16+ */
17+#ifndef TAB_DECORATOR_H
18+#define TAB_DECORATOR_H
19+
20+
21+#include <Region.h>
22+
23+#include "Decorator.h"
24+
25+
26+class Desktop;
27+
28+
29+class TabDecorator: public Decorator {
30+public:
31+ TabDecorator(DesktopSettings& settings,
32+ BRect frame, Desktop* desktop);
33+ virtual ~TabDecorator();
34+
35+protected:
36+ enum {
37+ COLOR_TAB_FRAME_LIGHT = 0,
38+ COLOR_TAB_FRAME_DARK = 1,
39+ COLOR_TAB = 2,
40+ COLOR_TAB_LIGHT = 3,
41+ COLOR_TAB_BEVEL = 4,
42+ COLOR_TAB_SHADOW = 5,
43+ COLOR_TAB_TEXT = 6
44+ };
45+
46+ enum {
47+ COLOR_BUTTON = 0,
48+ COLOR_BUTTON_LIGHT = 1
49+ };
50+
51+ enum Component {
52+ COMPONENT_TAB,
53+
54+ COMPONENT_CLOSE_BUTTON,
55+ COMPONENT_ZOOM_BUTTON,
56+
57+ COMPONENT_LEFT_BORDER,
58+ COMPONENT_RIGHT_BORDER,
59+ COMPONENT_TOP_BORDER,
60+ COMPONENT_BOTTOM_BORDER,
61+
62+ COMPONENT_RESIZE_CORNER
63+ };
64+
65+ typedef rgb_color ComponentColors[7];
66+
67+public:
68+ virtual void Draw(BRect updateRect);
69+ virtual void Draw();
70+
71+ virtual Region RegionAt(BPoint where, int32& tab) const;
72+
73+ virtual bool SetRegionHighlight(Region region,
74+ uint8 highlight, BRegion* dirty,
75+ int32 tab = -1);
76+
77+ virtual void UpdateColors(DesktopSettings& settings);
78+
79+protected:
80+ virtual void _DoLayout();
81+ virtual void _DoOutlineLayout();
82+ virtual void _DoTabLayout();
83+ void _DistributeTabSize(float delta);
84+
85+ virtual void _DrawFrame(BRect rect) = 0;
86+ virtual void _DrawOutlineFrame(BRect rect);
87+ virtual void _DrawTab(Decorator::Tab* tab, BRect r) = 0;
88+
89+ virtual void _DrawButtons(Decorator::Tab* tab,
90+ const BRect& invalid);
91+ virtual void _DrawClose(Decorator::Tab* tab, bool direct,
92+ BRect r) = 0;
93+ virtual void _DrawTitle(Decorator::Tab* tab, BRect r) = 0;
94+ virtual void _DrawZoom(Decorator::Tab* tab, bool direct,
95+ BRect r) = 0;
96+
97+ virtual void _SetTitle(Decorator::Tab* tab,
98+ const char* string,
99+ BRegion* updateRegion = NULL);
100+
101+ virtual void _MoveBy(BPoint offset);
102+ virtual void _ResizeBy(BPoint offset, BRegion* dirty);
103+
104+ virtual void _SetFocus(Decorator::Tab* tab);
105+ virtual bool _SetTabLocation(Decorator::Tab* tab,
106+ float location, bool isShifting,
107+ BRegion* updateRegion = NULL);
108+
109+ virtual bool _SetSettings(const BMessage& settings,
110+ BRegion* updateRegion = NULL);
111+
112+ virtual bool _AddTab(DesktopSettings& settings,
113+ int32 index = -1,
114+ BRegion* updateRegion = NULL);
115+ virtual bool _RemoveTab(int32 index,
116+ BRegion* updateRegion = NULL);
117+ virtual bool _MoveTab(int32 from, int32 to, bool isMoving,
118+ BRegion* updateRegion = NULL);
119+
120+ virtual void _GetFootprint(BRegion* region);
121+
122+ virtual void _GetButtonSizeAndOffset(const BRect& tabRect,
123+ float* offset, float* size,
124+ float* inset) const;
125+
126+ virtual void _UpdateFont(DesktopSettings& settings);
127+
128+private:
129+ void _LayoutTabItems(Decorator::Tab* tab,
130+ const BRect& tabRect);
131+
132+protected:
133+ inline float _DefaultTextOffset() const;
134+ inline float _SingleTabOffsetAndSize(float& tabSize);
135+
136+ void _CalculateTabsRegion();
137+
138+protected:
139+ BRegion fTabsRegion;
140+ BRect fOldMovingTab;
141+ float fBorderResizeLength, fResizeKnobSize;
142+
143+ rgb_color fFocusFrameColor;
144+
145+ rgb_color fFocusTabColor;
146+ rgb_color fFocusTabColorLight;
147+ rgb_color fFocusTabColorBevel;
148+ rgb_color fFocusTabColorShadow;
149+ rgb_color fFocusTextColor;
150+
151+ rgb_color fNonFocusFrameColor;
152+
153+ rgb_color fNonFocusTabColor;
154+ rgb_color fNonFocusTabColorLight;
155+ rgb_color fNonFocusTabColorBevel;
156+ rgb_color fNonFocusTabColorShadow;
157+ rgb_color fNonFocusTextColor;
158+};
159+
160+
161+#endif // TAB_DECORATOR_H
1@@ -0,0 +1 @@
2+#include <../private/app/TokenSpace.h>
1@@ -0,0 +1,70 @@
2+/*
3+ * Copyright 2005, Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * A handy front-end to agg::trans_affine transformation matrix.
7+ *
8+ */
9+
10+
11+#ifndef TRANSFORMABLE_H
12+#define TRANSFORMABLE_H
13+
14+#include <Archivable.h>
15+#include <Rect.h>
16+
17+#include <agg_trans_affine.h>
18+
19+class Transformable : public BArchivable,
20+ public agg::trans_affine {
21+ public:
22+ Transformable();
23+ Transformable(const Transformable& other);
24+ Transformable(const BMessage* archive);
25+ virtual ~Transformable();
26+
27+ // the BArchivable protocol
28+ // stores matrix directly to message, deep is ignored
29+ virtual status_t Archive(BMessage* into, bool deep = true) const;
30+
31+ void StoreTo(double matrix[6]) const;
32+ void LoadFrom(double matrix[6]);
33+
34+ // set to or combine with other matrix
35+ void SetTransformable(const Transformable& other);
36+ Transformable& operator=(const agg::trans_affine& other);
37+ Transformable& operator=(const Transformable& other);
38+ Transformable& Multiply(const Transformable& other);
39+ void Reset();
40+
41+ bool IsIdentity() const;
42+ bool IsDilation() const;
43+// bool operator==(const Transformable& other) const;
44+// bool operator!=(const Transformable& other) const;
45+
46+ // transforms coordiantes
47+ void Transform(double* x, double* y) const;
48+ void Transform(BPoint* point) const;
49+ BPoint Transform(const BPoint& point) const;
50+
51+ void InverseTransform(double* x, double* y) const;
52+ void InverseTransform(BPoint* point) const;
53+ BPoint InverseTransform(const BPoint& point) const;
54+
55+ // transforms the rectangle "bounds" and
56+ // returns the *bounding box* of that
57+ BRect TransformBounds(const BRect& bounds) const;
58+
59+ bool IsTranslationOnly() const;
60+
61+ // some convenience functions
62+ virtual void TranslateBy(BPoint offset);
63+ virtual void RotateBy(BPoint origin, double radians);
64+ virtual void ScaleBy(BPoint origin, double xScale, double yScale);
65+ virtual void ShearBy(BPoint origin, double xShear, double yShear);
66+
67+ virtual void TransformationChanged() {}
68+};
69+
70+#endif // TRANSFORMABLE_H
71+
1@@ -0,0 +1 @@
2+#include <../private/shared/TypeOperation.h>
1@@ -0,0 +1,75 @@
2+/*
3+ * Copyright 2005-2009, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef VIRTUAL_SCREEN_H
10+#define VIRTUAL_SCREEN_H
11+
12+
13+#include "ScreenConfigurations.h"
14+#include "ScreenManager.h"
15+
16+#include <Message.h>
17+
18+
19+class Desktop;
20+class DrawingEngine;
21+class HWInterface;
22+
23+
24+class VirtualScreen {
25+public:
26+ VirtualScreen();
27+ ~VirtualScreen();
28+
29+ ::DrawingEngine* DrawingEngine() const
30+ { return fDrawingEngine; }
31+
32+ // TODO: can we have a multiplexing HWInterface as well?
33+ // If not, this would need to be hidden, and only made
34+ // available for the Screen class
35+ ::HWInterface* HWInterface() const
36+ { return fHWInterface; }
37+
38+ status_t SetConfiguration(Desktop& desktop,
39+ ScreenConfigurations& configurations,
40+ uint32* _changedScreens = NULL);
41+
42+ status_t AddScreen(Screen* screen,
43+ ScreenConfigurations& configurations);
44+ status_t RemoveScreen(Screen* screen);
45+
46+ void UpdateFrame();
47+ BRect Frame() const;
48+
49+ // TODO: we need to play with a real multi-screen configuration to
50+ // figure out the specifics here
51+ void SetScreenFrame(int32 index, BRect frame);
52+
53+ Screen* ScreenAt(int32 index) const;
54+ Screen* ScreenByID(int32 id) const;
55+ BRect ScreenFrameAt(int32 index) const;
56+ int32 CountScreens() const;
57+
58+private:
59+ status_t _GetMode(Screen* screen,
60+ ScreenConfigurations& configurations,
61+ display_mode& mode) const;
62+ void _Reset();
63+
64+ struct screen_item {
65+ Screen* screen;
66+ BRect frame;
67+ // TODO: do we want to have a different color per screen as well?
68+ };
69+
70+ BRect fFrame;
71+ BObjectList<screen_item> fScreenList;
72+ ::DrawingEngine* fDrawingEngine;
73+ ::HWInterface* fHWInterface;
74+};
75+
76+#endif /* VIRTUAL_SCREEN_H */
1@@ -0,0 +1,62 @@
2+/*
3+ * Copyright 2010, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Clemens Zeidler <haiku@clemens-zeidler.de>
8+ */
9+
10+
11+#include "WindowBehaviour.h"
12+
13+
14+WindowBehaviour::WindowBehaviour()
15+ :
16+ fIsResizing(false),
17+ fIsDragging(false)
18+{
19+}
20+
21+
22+WindowBehaviour::~WindowBehaviour()
23+{
24+}
25+
26+
27+void
28+WindowBehaviour::ModifiersChanged(int32 modifiers)
29+{
30+}
31+
32+
33+bool
34+WindowBehaviour::AlterDeltaForSnap(Window* window, BPoint& delta, bigtime_t now)
35+{
36+ return false;
37+}
38+
39+
40+/*! \fn WindowBehaviour::MouseDown()
41+ \brief Handles a mouse-down message for the window.
42+
43+ Note that values passed and returned for the hit regions are only meaningful
44+ to the WindowBehavior subclass, save for the value 0, which is refers to an
45+ invalid region.
46+
47+ \param message The message.
48+ \param where The point where the mouse click happened.
49+ \param lastHitRegion The hit region of the previous click.
50+ \param clickCount The number of subsequent, no longer than double-click
51+ interval separated clicks that have happened so far. This number doesn't
52+ necessarily match the value in the message. It has already been
53+ pre-processed in order to avoid erroneous multi-clicks (e.g. when a
54+ different button has been used or a different window was targeted). This
55+ is an in-out variable. The method can reset the value to 1, if it
56+ doesn't want this event handled as a multi-click. Returning a different
57+ click hit region will also make the caller reset the click count.
58+ \param _hitRegion Set by the method to a value identifying the clicked
59+ decorator element. If not explicitly set, an invalid hit region (0) is
60+ assumed. Only needs to be set when returning \c true.
61+ \return \c true, if the event was a WindowBehaviour event and should be
62+ discarded.
63+*/
1@@ -0,0 +1,52 @@
2+/*
3+ * Copyright 2010, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Clemens Zeidler <haiku@clemens-zeidler.de>
8+ */
9+#ifndef WINDOW_BEHAVIOUR_H
10+#define WINDOW_BEHAVIOUR_H
11+
12+
13+#include <Region.h>
14+
15+#include "Decorator.h"
16+
17+
18+class BMessage;
19+class ClickTarget;
20+class Window;
21+
22+
23+class WindowBehaviour {
24+public:
25+ WindowBehaviour();
26+ virtual ~WindowBehaviour();
27+
28+ virtual bool MouseDown(BMessage* message, BPoint where,
29+ int32 lastHitRegion, int32& clickCount,
30+ int32& _hitRegion) = 0;
31+ virtual void MouseUp(BMessage* message, BPoint where) = 0;
32+ virtual void MouseMoved(BMessage *message, BPoint where,
33+ bool isFake) = 0;
34+
35+ virtual void ModifiersChanged(int32 modifiers);
36+
37+ bool IsDragging() const { return fIsDragging; }
38+ bool IsResizing() const { return fIsResizing; }
39+
40+protected:
41+ /*! The window is going to be moved by delta. This hook should be used to
42+ implement the magnetic screen border, i.e. alter the delta accordantly.
43+ \return true if delta has been modified. */
44+ virtual bool AlterDeltaForSnap(Window* window, BPoint& delta,
45+ bigtime_t now);
46+
47+protected:
48+ bool fIsResizing : 1;
49+ bool fIsDragging : 1;
50+};
51+
52+
53+#endif
+64,
-0
1@@ -0,0 +1,64 @@
2+/*
3+ * Copyright (c) 2005-2008, Haiku, Inc.
4+ * Distributed under the terms of the MIT license.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef WINDOW_LIST_H
10+#define WINDOW_LIST_H
11+
12+
13+#include <SupportDefs.h>
14+#include <Point.h>
15+
16+
17+class Window;
18+
19+
20+class WindowList {
21+public:
22+ WindowList(int32 index = 0);
23+ ~WindowList();
24+
25+ void SetIndex(int32 index);
26+ int32 Index() const { return fIndex; }
27+
28+ Window* FirstWindow() const { return fFirstWindow; }
29+ Window* LastWindow() const { return fLastWindow; }
30+
31+ void AddWindow(Window* window, Window* before = NULL);
32+ void RemoveWindow(Window* window);
33+
34+ bool HasWindow(Window* window) const;
35+ bool ValidateWindow(Window* window) const;
36+
37+ int32 Count() const;
38+ // O(n)
39+
40+private:
41+ int32 fIndex;
42+ Window* fFirstWindow;
43+ Window* fLastWindow;
44+};
45+
46+enum window_lists {
47+ kAllWindowList = 32,
48+ kSubsetList,
49+ kFocusList,
50+ kWorkingList,
51+
52+ kListCount
53+};
54+
55+struct window_anchor {
56+ window_anchor();
57+
58+ Window* next;
59+ Window* previous;
60+ BPoint position;
61+};
62+
63+extern const BPoint kInvalidWindowPosition;
64+
65+#endif // WINDOW_LIST_H
1@@ -0,0 +1,35 @@
2+/*
3+ * Copyright 2005-2008, Jérôme Duval, jerome.duval@free.fr.
4+ * Distributed under the terms of the MIT License.
5+ */
6+#ifndef _WINDOW_PRIVATE_H
7+#define _WINDOW_PRIVATE_H
8+
9+
10+#include <Window.h>
11+
12+
13+/* Private window looks */
14+
15+const window_look kDesktopWindowLook = window_look(4);
16+const window_look kLeftTitledWindowLook = window_look(25);
17+
18+/* Private window feels */
19+
20+const window_feel kDesktopWindowFeel = window_feel(1024);
21+const window_feel kMenuWindowFeel = window_feel(1025);
22+const window_feel kWindowScreenFeel = window_feel(1026);
23+const window_feel kPasswordWindowFeel = window_feel(1027);
24+const window_feel kOffscreenWindowFeel = window_feel(1028);
25+
26+/* Private window types */
27+
28+const window_type kWindowScreenWindow = window_type(1026);
29+
30+/* Private window flags */
31+
32+const uint32 kWindowScreenFlag = 0x10000;
33+const uint32 kAcceptKeyboardFocusFlag = 0x40000;
34+ // Accept keyboard input even if B_AVOID_FOCUS is set
35+
36+#endif // _WINDOW_PRIVATE_H
+52,
-0
1@@ -0,0 +1,52 @@
2+/*
3+ * Copyright 2005-2013, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef WORKSPACE_H
10+#define WORKSPACE_H
11+
12+
13+#include <InterfaceDefs.h>
14+
15+
16+class Desktop;
17+class Window;
18+
19+
20+/*! Workspace objects are intended to be short-lived. You create them while
21+ already holding a lock to the Desktop read-write lock and then you can use
22+ them to query information, and then you destroy them again, for example by
23+ letting them go out of scope.
24+*/
25+class Workspace {
26+public:
27+ Workspace(Desktop& desktop, int32 index,
28+ bool readOnly = false);
29+ ~Workspace();
30+
31+ const rgb_color& Color() const;
32+ void SetColor(const rgb_color& color,
33+ bool makeDefault);
34+ bool IsCurrent() const
35+ { return fCurrentWorkspace; }
36+
37+ status_t GetNextWindow(Window*& _window,
38+ BPoint& _leftTop);
39+ status_t GetPreviousWindow(Window*& _window,
40+ BPoint& _leftTop);
41+ void RewindWindows();
42+
43+ class Private;
44+
45+private:
46+ Workspace::Private& fWorkspace;
47+ Desktop& fDesktop;
48+ Window* fCurrent;
49+ bool fCurrentWorkspace;
50+};
51+
52+
53+#endif /* WORKSPACE_H */
1@@ -0,0 +1,71 @@
2+/*
3+ * Copyright 2005-2009, Haiku.
4+ * Distributed under the terms of the MIT License.
5+ *
6+ * Authors:
7+ * Axel Dörfler, axeld@pinc-software.de
8+ */
9+#ifndef WORKSPACE_PRIVATE_H
10+#define WORKSPACE_PRIVATE_H
11+
12+
13+#include "ScreenConfigurations.h"
14+#include "WindowList.h"
15+#include "Workspace.h"
16+
17+#include <Accelerant.h>
18+#include <ObjectList.h>
19+#include <String.h>
20+
21+
22+struct display_info {
23+ BString identifier;
24+ BPoint origin;
25+ display_mode mode;
26+};
27+
28+
29+class Workspace::Private {
30+public:
31+ Private();
32+ ~Private();
33+
34+ int32 Index() const { return fWindows.Index(); }
35+
36+ WindowList& Windows() { return fWindows; }
37+
38+ // displays
39+
40+ void SetDisplaysFromDesktop(Desktop* desktop);
41+
42+ int32 CountDisplays() const
43+ { return fDisplays.CountItems(); }
44+ const display_info* DisplayAt(int32 index) const
45+ { return fDisplays.ItemAt(index); }
46+
47+ // configuration
48+
49+ const rgb_color& Color() const { return fColor; }
50+ void SetColor(const rgb_color& color);
51+
52+ ScreenConfigurations& CurrentScreenConfiguration()
53+ { return fCurrentScreenConfiguration; }
54+ ScreenConfigurations& StoredScreenConfiguration()
55+ { return fStoredScreenConfiguration; }
56+
57+ void RestoreConfiguration(const BMessage& settings);
58+ void StoreConfiguration(BMessage& settings);
59+
60+private:
61+ void _SetDefaults();
62+
63+ WindowList fWindows;
64+
65+ BObjectList<display_info> fDisplays;
66+
67+ ScreenConfigurations fStoredScreenConfiguration;
68+ ScreenConfigurations fCurrentScreenConfiguration;
69+ rgb_color fColor;
70+};
71+
72+#endif /* WORKSPACE_PRIVATE_H */
+560,
-0
1@@ -0,0 +1,560 @@
2+//----------------------------------------------------------------------------
3+// Anti-Grain Geometry - Version 2.4
4+// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5+//
6+// Permission to copy, use, modify, sell and distribute this software
7+// is granted provided this copyright notice appears in all copies.
8+// This software is provided "as is" without express or implied
9+// warranty, and with no claim as to its suitability for any purpose.
10+//
11+//----------------------------------------------------------------------------
12+// Contact: mcseem@antigrain.com
13+// mcseemagg@yahoo.com
14+// http://www.antigrain.com
15+//----------------------------------------------------------------------------
16+
17+#ifndef AGG_BASICS_INCLUDED
18+#define AGG_BASICS_INCLUDED
19+
20+#include <math.h>
21+#include "agg_config.h"
22+
23+//---------------------------------------------------------AGG_CUSTOM_ALLOCATOR
24+#ifdef AGG_CUSTOM_ALLOCATOR
25+#include "agg_allocator.h"
26+#else
27+namespace agg
28+{
29+ // The policy of all AGG containers and memory allocation strategy
30+ // in general is that no allocated data requires explicit construction.
31+ // It means that the allocator can be really simple; you can even
32+ // replace new/delete to malloc/free. The constructors and destructors
33+ // won't be called in this case, however everything will remain working.
34+ // The second argument of deallocate() is the size of the allocated
35+ // block. You can use this information if you wish.
36+ //------------------------------------------------------------pod_allocator
37+ template<class T> struct pod_allocator
38+ {
39+ static T* allocate(unsigned num) { return new T [num]; }
40+ static void deallocate(T* ptr, unsigned) { delete [] ptr; }
41+ };
42+
43+ // Single object allocator. It's also can be replaced with your custom
44+ // allocator. The difference is that it can only allocate a single
45+ // object and the constructor and destructor must be called.
46+ // In AGG there is no need to allocate an array of objects with
47+ // calling their constructors (only single ones). So that, if you
48+ // replace these new/delete to malloc/free make sure that the in-place
49+ // new is called and take care of calling the destructor too.
50+ //------------------------------------------------------------obj_allocator
51+ template<class T> struct obj_allocator
52+ {
53+ static T* allocate() { return new T; }
54+ static void deallocate(T* ptr) { delete ptr; }
55+ };
56+}
57+#endif
58+
59+
60+//-------------------------------------------------------- Default basic types
61+//
62+// If the compiler has different capacity of the basic types you can redefine
63+// them via the compiler command line or by generating agg_config.h that is
64+// empty by default.
65+//
66+#ifndef AGG_INT8
67+#define AGG_INT8 signed char
68+#endif
69+
70+#ifndef AGG_INT8U
71+#define AGG_INT8U unsigned char
72+#endif
73+
74+#ifndef AGG_INT16
75+#define AGG_INT16 short
76+#endif
77+
78+#ifndef AGG_INT16U
79+#define AGG_INT16U unsigned short
80+#endif
81+
82+#ifndef AGG_INT32
83+#define AGG_INT32 int
84+#endif
85+
86+#ifndef AGG_INT32U
87+#define AGG_INT32U unsigned
88+#endif
89+
90+#ifndef AGG_INT64
91+#if defined(_MSC_VER) || defined(__BORLANDC__)
92+#define AGG_INT64 signed __int64
93+#else
94+#define AGG_INT64 signed long long
95+#endif
96+#endif
97+
98+#ifndef AGG_INT64U
99+#if defined(_MSC_VER) || defined(__BORLANDC__)
100+#define AGG_INT64U unsigned __int64
101+#else
102+#define AGG_INT64U unsigned long long
103+#endif
104+#endif
105+
106+//------------------------------------------------ Some fixes for MS Visual C++
107+#if defined(_MSC_VER)
108+#pragma warning(disable:4786) // Identifier was truncated...
109+#endif
110+
111+#if defined(_MSC_VER)
112+#define AGG_INLINE __forceinline
113+#else
114+#define AGG_INLINE inline
115+#endif
116+
117+namespace agg
118+{
119+ //-------------------------------------------------------------------------
120+ typedef AGG_INT8 int8; //----int8
121+ typedef AGG_INT8U int8u; //----int8u
122+ typedef AGG_INT16 int16; //----int16
123+ typedef AGG_INT16U int16u; //----int16u
124+ typedef AGG_INT32 int32; //----int32
125+ typedef AGG_INT32U int32u; //----int32u
126+ typedef AGG_INT64 int64; //----int64
127+ typedef AGG_INT64U int64u; //----int64u
128+
129+#if defined(AGG_FISTP)
130+#pragma warning(push)
131+#pragma warning(disable : 4035) //Disable warning "no return value"
132+ AGG_INLINE int iround(double v) //-------iround
133+ {
134+ int t;
135+ __asm fld qword ptr [v]
136+ __asm fistp dword ptr [t]
137+ __asm mov eax, dword ptr [t]
138+ }
139+ AGG_INLINE unsigned uround(double v) //-------uround
140+ {
141+ unsigned t;
142+ __asm fld qword ptr [v]
143+ __asm fistp dword ptr [t]
144+ __asm mov eax, dword ptr [t]
145+ }
146+#pragma warning(pop)
147+ AGG_INLINE int ifloor(double v)
148+ {
149+ return int(floor(v));
150+ }
151+ AGG_INLINE unsigned ufloor(double v) //-------ufloor
152+ {
153+ return unsigned(floor(v));
154+ }
155+ AGG_INLINE int iceil(double v)
156+ {
157+ return int(ceil(v));
158+ }
159+ AGG_INLINE unsigned uceil(double v) //--------uceil
160+ {
161+ return unsigned(ceil(v));
162+ }
163+#elif defined(AGG_QIFIST)
164+ AGG_INLINE int iround(double v)
165+ {
166+ return int(v);
167+ }
168+ AGG_INLINE int uround(double v)
169+ {
170+ return unsigned(v);
171+ }
172+ AGG_INLINE int ifloor(double v)
173+ {
174+ return int(floor(v));
175+ }
176+ AGG_INLINE unsigned ufloor(double v)
177+ {
178+ return unsigned(floor(v));
179+ }
180+ AGG_INLINE int iceil(double v)
181+ {
182+ return int(ceil(v));
183+ }
184+ AGG_INLINE unsigned uceil(double v)
185+ {
186+ return unsigned(ceil(v));
187+ }
188+#else
189+ AGG_INLINE int iround(double v)
190+ {
191+ return int((v < 0.0) ? v - 0.5 : v + 0.5);
192+ }
193+ AGG_INLINE int uround(double v)
194+ {
195+ return unsigned(v + 0.5);
196+ }
197+ AGG_INLINE int ifloor(double v)
198+ {
199+ int i = int(v);
200+ return i - (i > v);
201+ }
202+ AGG_INLINE unsigned ufloor(double v)
203+ {
204+ return unsigned(v);
205+ }
206+ AGG_INLINE int iceil(double v)
207+ {
208+ return int(ceil(v));
209+ }
210+ AGG_INLINE unsigned uceil(double v)
211+ {
212+ return unsigned(ceil(v));
213+ }
214+#endif
215+
216+ //---------------------------------------------------------------saturation
217+ template<int Limit> struct saturation
218+ {
219+ AGG_INLINE static int iround(double v)
220+ {
221+ if(v < double(-Limit)) return -Limit;
222+ if(v > double( Limit)) return Limit;
223+ return agg::iround(v);
224+ }
225+ };
226+
227+ //------------------------------------------------------------------mul_one
228+ template<unsigned Shift> struct mul_one
229+ {
230+ AGG_INLINE static unsigned mul(unsigned a, unsigned b)
231+ {
232+ unsigned q = a * b + (1 << (Shift-1));
233+ return (q + (q >> Shift)) >> Shift;
234+ }
235+ };
236+
237+ //-------------------------------------------------------------------------
238+ typedef unsigned char cover_type; //----cover_type
239+ enum cover_scale_e
240+ {
241+ cover_shift = 8, //----cover_shift
242+ cover_size = 1 << cover_shift, //----cover_size
243+ cover_mask = cover_size - 1, //----cover_mask
244+ cover_none = 0, //----cover_none
245+ cover_full = cover_mask //----cover_full
246+ };
247+
248+ //----------------------------------------------------poly_subpixel_scale_e
249+ // These constants determine the subpixel accuracy, to be more precise,
250+ // the number of bits of the fractional part of the coordinates.
251+ // The possible coordinate capacity in bits can be calculated by formula:
252+ // sizeof(int) * 8 - poly_subpixel_shift, i.e, for 32-bit integers and
253+ // 8-bits fractional part the capacity is 24 bits.
254+ enum poly_subpixel_scale_e
255+ {
256+ poly_subpixel_shift = 8, //----poly_subpixel_shift
257+ poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale
258+ poly_subpixel_mask = poly_subpixel_scale-1 //----poly_subpixel_mask
259+ };
260+
261+ //----------------------------------------------------------filling_rule_e
262+ enum filling_rule_e
263+ {
264+ fill_non_zero,
265+ fill_even_odd
266+ };
267+
268+ //-----------------------------------------------------------------------pi
269+ const double pi = 3.14159265358979323846;
270+
271+ //------------------------------------------------------------------deg2rad
272+ inline double deg2rad(double deg)
273+ {
274+ return deg * pi / 180.0;
275+ }
276+
277+ //------------------------------------------------------------------rad2deg
278+ inline double rad2deg(double rad)
279+ {
280+ return rad * 180.0 / pi;
281+ }
282+
283+ //----------------------------------------------------------------rect_base
284+ template<class T> struct rect_base
285+ {
286+ typedef T value_type;
287+ typedef rect_base<T> self_type;
288+ T x1, y1, x2, y2;
289+
290+ rect_base() {}
291+ rect_base(T x1_, T y1_, T x2_, T y2_) :
292+ x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}
293+
294+ void init(T x1_, T y1_, T x2_, T y2_)
295+ {
296+ x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_;
297+ }
298+
299+ const self_type& normalize()
300+ {
301+ T t;
302+ if(x1 > x2) { t = x1; x1 = x2; x2 = t; }
303+ if(y1 > y2) { t = y1; y1 = y2; y2 = t; }
304+ return *this;
305+ }
306+
307+ bool clip(const self_type& r)
308+ {
309+ if(x2 > r.x2) x2 = r.x2;
310+ if(y2 > r.y2) y2 = r.y2;
311+ if(x1 < r.x1) x1 = r.x1;
312+ if(y1 < r.y1) y1 = r.y1;
313+ return x1 <= x2 && y1 <= y2;
314+ }
315+
316+ bool is_valid() const
317+ {
318+ return x1 <= x2 && y1 <= y2;
319+ }
320+
321+ bool hit_test(T x, T y) const
322+ {
323+ return (x >= x1 && x <= x2 && y >= y1 && y <= y2);
324+ }
325+
326+ bool overlaps(const self_type& r) const
327+ {
328+ return !(r.x1 > x2 || r.x2 < x1
329+ || r.y1 > y2 || r.y2 < y1);
330+ }
331+ };
332+
333+ //-----------------------------------------------------intersect_rectangles
334+ template<class Rect>
335+ inline Rect intersect_rectangles(const Rect& r1, const Rect& r2)
336+ {
337+ Rect r = r1;
338+
339+ // First process x2,y2 because the other order
340+ // results in Internal Compiler Error under
341+ // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in
342+ // case of "Maximize Speed" optimization option.
343+ //-----------------
344+ if(r.x2 > r2.x2) r.x2 = r2.x2;
345+ if(r.y2 > r2.y2) r.y2 = r2.y2;
346+ if(r.x1 < r2.x1) r.x1 = r2.x1;
347+ if(r.y1 < r2.y1) r.y1 = r2.y1;
348+ return r;
349+ }
350+
351+
352+ //---------------------------------------------------------unite_rectangles
353+ template<class Rect>
354+ inline Rect unite_rectangles(const Rect& r1, const Rect& r2)
355+ {
356+ Rect r = r1;
357+ if(r.x2 < r2.x2) r.x2 = r2.x2;
358+ if(r.y2 < r2.y2) r.y2 = r2.y2;
359+ if(r.x1 > r2.x1) r.x1 = r2.x1;
360+ if(r.y1 > r2.y1) r.y1 = r2.y1;
361+ return r;
362+ }
363+
364+ typedef rect_base<int> rect_i; //----rect_i
365+ typedef rect_base<float> rect_f; //----rect_f
366+ typedef rect_base<double> rect_d; //----rect_d
367+
368+ //---------------------------------------------------------path_commands_e
369+ enum path_commands_e
370+ {
371+ path_cmd_stop = 0, //----path_cmd_stop
372+ path_cmd_move_to = 1, //----path_cmd_move_to
373+ path_cmd_line_to = 2, //----path_cmd_line_to
374+ path_cmd_curve3 = 3, //----path_cmd_curve3
375+ path_cmd_curve4 = 4, //----path_cmd_curve4
376+ path_cmd_curveN = 5, //----path_cmd_curveN
377+ path_cmd_catrom = 6, //----path_cmd_catrom
378+ path_cmd_ubspline = 7, //----path_cmd_ubspline
379+ path_cmd_end_poly = 0x0F, //----path_cmd_end_poly
380+ path_cmd_mask = 0x0F //----path_cmd_mask
381+ };
382+
383+ //------------------------------------------------------------path_flags_e
384+ enum path_flags_e
385+ {
386+ path_flags_none = 0, //----path_flags_none
387+ path_flags_ccw = 0x10, //----path_flags_ccw
388+ path_flags_cw = 0x20, //----path_flags_cw
389+ path_flags_close = 0x40, //----path_flags_close
390+ path_flags_mask = 0xF0 //----path_flags_mask
391+ };
392+
393+ //---------------------------------------------------------------is_vertex
394+ inline bool is_vertex(unsigned c)
395+ {
396+ return c >= path_cmd_move_to && c < path_cmd_end_poly;
397+ }
398+
399+ //--------------------------------------------------------------is_drawing
400+ inline bool is_drawing(unsigned c)
401+ {
402+ return c >= path_cmd_line_to && c < path_cmd_end_poly;
403+ }
404+
405+ //-----------------------------------------------------------------is_stop
406+ inline bool is_stop(unsigned c)
407+ {
408+ return c == path_cmd_stop;
409+ }
410+
411+ //--------------------------------------------------------------is_move_to
412+ inline bool is_move_to(unsigned c)
413+ {
414+ return c == path_cmd_move_to;
415+ }
416+
417+ //--------------------------------------------------------------is_line_to
418+ inline bool is_line_to(unsigned c)
419+ {
420+ return c == path_cmd_line_to;
421+ }
422+
423+ //----------------------------------------------------------------is_curve
424+ inline bool is_curve(unsigned c)
425+ {
426+ return c == path_cmd_curve3 || c == path_cmd_curve4;
427+ }
428+
429+ //---------------------------------------------------------------is_curve3
430+ inline bool is_curve3(unsigned c)
431+ {
432+ return c == path_cmd_curve3;
433+ }
434+
435+ //---------------------------------------------------------------is_curve4
436+ inline bool is_curve4(unsigned c)
437+ {
438+ return c == path_cmd_curve4;
439+ }
440+
441+ //-------------------------------------------------------------is_end_poly
442+ inline bool is_end_poly(unsigned c)
443+ {
444+ return (c & path_cmd_mask) == path_cmd_end_poly;
445+ }
446+
447+ //----------------------------------------------------------------is_close
448+ inline bool is_close(unsigned c)
449+ {
450+ return (c & ~(path_flags_cw | path_flags_ccw)) ==
451+ (path_cmd_end_poly | path_flags_close);
452+ }
453+
454+ //------------------------------------------------------------is_next_poly
455+ inline bool is_next_poly(unsigned c)
456+ {
457+ return is_stop(c) || is_move_to(c) || is_end_poly(c);
458+ }
459+
460+ //-------------------------------------------------------------------is_cw
461+ inline bool is_cw(unsigned c)
462+ {
463+ return (c & path_flags_cw) != 0;
464+ }
465+
466+ //------------------------------------------------------------------is_ccw
467+ inline bool is_ccw(unsigned c)
468+ {
469+ return (c & path_flags_ccw) != 0;
470+ }
471+
472+ //-------------------------------------------------------------is_oriented
473+ inline bool is_oriented(unsigned c)
474+ {
475+ return (c & (path_flags_cw | path_flags_ccw)) != 0;
476+ }
477+
478+ //---------------------------------------------------------------is_closed
479+ inline bool is_closed(unsigned c)
480+ {
481+ return (c & path_flags_close) != 0;
482+ }
483+
484+ //----------------------------------------------------------get_close_flag
485+ inline unsigned get_close_flag(unsigned c)
486+ {
487+ return c & path_flags_close;
488+ }
489+
490+ //-------------------------------------------------------clear_orientation
491+ inline unsigned clear_orientation(unsigned c)
492+ {
493+ return c & ~(path_flags_cw | path_flags_ccw);
494+ }
495+
496+ //---------------------------------------------------------get_orientation
497+ inline unsigned get_orientation(unsigned c)
498+ {
499+ return c & (path_flags_cw | path_flags_ccw);
500+ }
501+
502+ //---------------------------------------------------------set_orientation
503+ inline unsigned set_orientation(unsigned c, unsigned o)
504+ {
505+ return clear_orientation(c) | o;
506+ }
507+
508+ //--------------------------------------------------------------point_base
509+ template<class T> struct point_base
510+ {
511+ typedef T value_type;
512+ T x,y;
513+ point_base() {}
514+ point_base(T x_, T y_) : x(x_), y(y_) {}
515+ };
516+ typedef point_base<int> point_i; //-----point_i
517+ typedef point_base<float> point_f; //-----point_f
518+ typedef point_base<double> point_d; //-----point_d
519+
520+ //-------------------------------------------------------------vertex_base
521+ template<class T> struct vertex_base
522+ {
523+ typedef T value_type;
524+ T x,y;
525+ unsigned cmd;
526+ vertex_base() {}
527+ vertex_base(T x_, T y_, unsigned cmd_) : x(x_), y(y_), cmd(cmd_) {}
528+ };
529+ typedef vertex_base<int> vertex_i; //-----vertex_i
530+ typedef vertex_base<float> vertex_f; //-----vertex_f
531+ typedef vertex_base<double> vertex_d; //-----vertex_d
532+
533+ //----------------------------------------------------------------row_info
534+ template<class T> struct row_info
535+ {
536+ int x1, x2;
537+ T* ptr;
538+ row_info() {}
539+ row_info(int x1_, int x2_, T* ptr_) : x1(x1_), x2(x2_), ptr(ptr_) {}
540+ };
541+
542+ //----------------------------------------------------------const_row_info
543+ template<class T> struct const_row_info
544+ {
545+ int x1, x2;
546+ const T* ptr;
547+ const_row_info() {}
548+ const_row_info(int x1_, int x2_, const T* ptr_) :
549+ x1(x1_), x2(x2_), ptr(ptr_) {}
550+ };
551+
552+ //------------------------------------------------------------is_equal_eps
553+ template<class T> inline bool is_equal_eps(T v1, T v2, T epsilon)
554+ {
555+ return fabs(v1 - v2) <= double(epsilon);
556+ }
557+}
558+
559+
560+#endif
561+
+26,
-0
1@@ -0,0 +1,26 @@
2+#ifndef AGG_CONFIG_INCLUDED
3+#define AGG_CONFIG_INCLUDED
4+
5+// This file can be used to redefine the default basic types such as:
6+//
7+// AGG_INT8
8+// AGG_INT8U
9+// AGG_INT16
10+// AGG_INT16U
11+// AGG_INT32
12+// AGG_INT32U
13+// AGG_INT64
14+// AGG_INT64U
15+//
16+// Just replace this file with new defines if necessary.
17+// For example, if your compiler doesn't have a 64 bit integer type
18+// you can still use AGG if you define the follows:
19+//
20+// #define AGG_INT64 int
21+// #define AGG_INT64U unsigned
22+//
23+// It will result in overflow in 16 bit-per-component image/pattern resampling
24+// but it won't result any crash and the rest of the library will remain
25+// fully functional.
26+
27+#endif
1@@ -0,0 +1,409 @@
2+//----------------------------------------------------------------------------
3+// Anti-Grain Geometry - Version 2.4
4+// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5+//
6+// Permission to copy, use, modify, sell and distribute this software
7+// is granted provided this copyright notice appears in all copies.
8+// This software is provided "as is" without express or implied
9+// warranty, and with no claim as to its suitability for any purpose.
10+//
11+//----------------------------------------------------------------------------
12+// Contact: mcseem@antigrain.com
13+// mcseemagg@yahoo.com
14+// http://www.antigrain.com
15+//----------------------------------------------------------------------------
16+//
17+// Affine transformation classes.
18+//
19+//----------------------------------------------------------------------------
20+#ifndef AGG_TRANS_AFFINE_INCLUDED
21+#define AGG_TRANS_AFFINE_INCLUDED
22+
23+#include <math.h>
24+#include "agg_basics.h"
25+
26+namespace agg
27+{
28+ const double affine_epsilon = 1e-14; // About of precision of doubles
29+
30+ //============================================================trans_affine
31+ //
32+ // See Implementation agg_trans_affine.cpp
33+ //
34+ // Affine transformation are linear transformations in Cartesian coordinates
35+ // (strictly speaking not only in Cartesian, but for the beginning we will
36+ // think so). They are rotation, scaling, translation and skewing.
37+ // After any affine transformation a line segment remains a line segment
38+ // and it will never become a curve.
39+ //
40+ // There will be no math about matrix calculations, since it has been
41+ // described many times. Ask yourself a very simple question:
42+ // "why do we need to understand and use some matrix stuff instead of just
43+ // rotating, scaling and so on". The answers are:
44+ //
45+ // 1. Any combination of transformations can be done by only 4 multiplications
46+ // and 4 additions in floating point.
47+ // 2. One matrix transformation is equivalent to the number of consecutive
48+ // discrete transformations, i.e. the matrix "accumulates" all transformations
49+ // in the order of their settings. Suppose we have 4 transformations:
50+ // * rotate by 30 degrees,
51+ // * scale X to 2.0,
52+ // * scale Y to 1.5,
53+ // * move to (100, 100).
54+ // The result will depend on the order of these transformations,
55+ // and the advantage of matrix is that the sequence of discret calls:
56+ // rotate(30), scaleX(2.0), scaleY(1.5), move(100,100)
57+ // will have exactly the same result as the following matrix transformations:
58+ //
59+ // affine_matrix m;
60+ // m *= rotate_matrix(30);
61+ // m *= scaleX_matrix(2.0);
62+ // m *= scaleY_matrix(1.5);
63+ // m *= move_matrix(100,100);
64+ //
65+ // m.transform_my_point_at_last(x, y);
66+ //
67+ // What is the good of it? In real life we will set-up the matrix only once
68+ // and then transform many points, let alone the convenience to set any
69+ // combination of transformations.
70+ //
71+ // So, how to use it? Very easy - literally as it's shown above. Not quite,
72+ // let us write a correct example:
73+ //
74+ // agg::trans_affine m;
75+ // m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0);
76+ // m *= agg::trans_affine_scaling(2.0, 1.5);
77+ // m *= agg::trans_affine_translation(100.0, 100.0);
78+ // m.transform(&x, &y);
79+ //
80+ // The affine matrix is all you need to perform any linear transformation,
81+ // but all transformations have origin point (0,0). It means that we need to
82+ // use 2 translations if we want to rotate someting around (100,100):
83+ //
84+ // m *= agg::trans_affine_translation(-100.0, -100.0); // move to (0,0)
85+ // m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0); // rotate
86+ // m *= agg::trans_affine_translation(100.0, 100.0); // move back to (100,100)
87+ //----------------------------------------------------------------------
88+ class trans_affine
89+ {
90+ public:
91+ //------------------------------------------ Construction
92+ // Construct an identity matrix - it does not transform anything
93+ trans_affine() :
94+ m0(1.0), m1(0.0), m2(0.0), m3(1.0), m4(0.0), m5(0.0)
95+ {}
96+
97+ // Construct a custom matrix. Usually used in derived classes
98+ trans_affine(double v0, double v1, double v2, double v3, double v4, double v5) :
99+ m0(v0), m1(v1), m2(v2), m3(v3), m4(v4), m5(v5)
100+ {}
101+
102+ // Construct a matrix to transform a parallelogram to another one.
103+ trans_affine(const double* rect, const double* parl)
104+ {
105+ parl_to_parl(rect, parl);
106+ }
107+
108+ // Construct a matrix to transform a rectangle to a parallelogram.
109+ trans_affine(double x1, double y1, double x2, double y2,
110+ const double* parl)
111+ {
112+ rect_to_parl(x1, y1, x2, y2, parl);
113+ }
114+
115+ // Construct a matrix to transform a parallelogram to a rectangle.
116+ trans_affine(const double* parl,
117+ double x1, double y1, double x2, double y2)
118+ {
119+ parl_to_rect(parl, x1, y1, x2, y2);
120+ }
121+
122+
123+ //---------------------------------- Parellelogram transformations
124+ // Calculate a matrix to transform a parallelogram to another one.
125+ // src and dst are pointers to arrays of three points
126+ // (double[6], x,y,...) that identify three corners of the
127+ // parallelograms assuming implicit fourth points.
128+ // There are also transformations rectangtle to parallelogram and
129+ // parellelogram to rectangle
130+ const trans_affine& parl_to_parl(const double* src,
131+ const double* dst);
132+
133+ const trans_affine& rect_to_parl(double x1, double y1,
134+ double x2, double y2,
135+ const double* parl);
136+
137+ const trans_affine& parl_to_rect(const double* parl,
138+ double x1, double y1,
139+ double x2, double y2);
140+
141+
142+ //------------------------------------------ Operations
143+ // Reset - actually load an identity matrix
144+ const trans_affine& reset();
145+
146+ // Multiply matrix to another one
147+ const trans_affine& multiply(const trans_affine& m);
148+
149+ // Multiply "m" to "this" and assign the result to "this"
150+ const trans_affine& premultiply(const trans_affine& m);
151+
152+ // Multiply matrix to inverse of another one
153+ const trans_affine& multiply_inv(const trans_affine& m);
154+
155+ // Multiply inverse of "m" to "this" and assign the result to "this"
156+ const trans_affine& premultiply_inv(const trans_affine& m);
157+
158+ // Invert matrix. Do not try to invert degenerate matrices,
159+ // there's no check for validity. If you set scale to 0 and
160+ // then try to invert matrix, expect unpredictable result.
161+ const trans_affine& invert();
162+
163+ // Mirroring around X
164+ const trans_affine& flip_x();
165+
166+ // Mirroring around Y
167+ const trans_affine& flip_y();
168+
169+ //------------------------------------------- Load/Store
170+ // Store matrix to an array [6] of double
171+ void store_to(double* m) const
172+ {
173+ *m++ = m0; *m++ = m1; *m++ = m2; *m++ = m3; *m++ = m4; *m++ = m5;
174+ }
175+
176+ // Load matrix from an array [6] of double
177+ const trans_affine& load_from(const double* m)
178+ {
179+ m0 = *m++; m1 = *m++; m2 = *m++; m3 = *m++; m4 = *m++; m5 = *m++;
180+ return *this;
181+ }
182+
183+ //------------------------------------------- Operators
184+
185+ // Multiply current matrix to another one
186+ const trans_affine& operator *= (const trans_affine& m)
187+ {
188+ return multiply(m);
189+ }
190+
191+ // Multiply current matrix to inverse of another one
192+ const trans_affine& operator /= (const trans_affine& m)
193+ {
194+ return multiply_inv(m);
195+ }
196+
197+ // Multiply current matrix to another one and return
198+ // the result in a separete matrix.
199+ trans_affine operator * (const trans_affine& m) const
200+ {
201+ return trans_affine(*this).multiply(m);
202+ }
203+
204+ // Multiply current matrix to inverse of another one
205+ // and return the result in a separete matrix.
206+ trans_affine operator / (const trans_affine& m) const
207+ {
208+ return trans_affine(*this).multiply_inv(m);
209+ }
210+
211+ // Calculate and return the inverse matrix
212+ trans_affine operator ~ () const
213+ {
214+ trans_affine ret = *this;
215+ return ret.invert();
216+ }
217+
218+ // Equal operator with default epsilon
219+ bool operator == (const trans_affine& m) const
220+ {
221+ return is_equal(m, affine_epsilon);
222+ }
223+
224+ // Not Equal operator with default epsilon
225+ bool operator != (const trans_affine& m) const
226+ {
227+ return !is_equal(m, affine_epsilon);
228+ }
229+
230+ //-------------------------------------------- Transformations
231+ // Direct transformation x and y
232+ void transform(double* x, double* y) const;
233+
234+ // Direct transformation x and y, 2x2 matrix only, no translation
235+ void transform_2x2(double* x, double* y) const;
236+
237+ // Inverse transformation x and y. It works slower than the
238+ // direct transformation, so if the performance is critical
239+ // it's better to invert() the matrix and then use transform()
240+ void inverse_transform(double* x, double* y) const;
241+
242+ //-------------------------------------------- Auxiliary
243+ // Calculate the determinant of matrix
244+ double determinant() const
245+ {
246+ return 1.0 / (m0 * m3 - m1 * m2);
247+ }
248+
249+ // Get the average scale (by X and Y).
250+ // Basically used to calculate the approximation_scale when
251+ // decomposinting curves into line segments.
252+ double scale() const;
253+
254+ // Check to see if it's an identity matrix
255+ bool is_identity(double epsilon = affine_epsilon) const;
256+
257+ // Check to see if two matrices are equal
258+ bool is_equal(const trans_affine& m, double epsilon = affine_epsilon) const;
259+
260+ // Determine the major parameters. Use carefully considering degenerate matrices
261+ double rotation() const;
262+ void translation(double* dx, double* dy) const;
263+ void scaling(double* sx, double* sy) const;
264+ void scaling_abs(double* sx, double* sy) const
265+ {
266+ *sx = sqrt(m0*m0 + m2*m2);
267+ *sy = sqrt(m1*m1 + m3*m3);
268+ }
269+
270+ private:
271+ double m0;
272+ double m1;
273+ double m2;
274+ double m3;
275+ double m4;
276+ double m5;
277+ };
278+
279+ //------------------------------------------------------------------------
280+ inline void trans_affine::transform(double* x, double* y) const
281+ {
282+ register double tx = *x;
283+ *x = tx * m0 + *y * m2 + m4;
284+ *y = tx * m1 + *y * m3 + m5;
285+ }
286+
287+ //------------------------------------------------------------------------
288+ inline void trans_affine::transform_2x2(double* x, double* y) const
289+ {
290+ register double tx = *x;
291+ *x = tx * m0 + *y * m2;
292+ *y = tx * m1 + *y * m3;
293+ }
294+
295+ //------------------------------------------------------------------------
296+ inline void trans_affine::inverse_transform(double* x, double* y) const
297+ {
298+ register double d = determinant();
299+ register double a = (*x - m4) * d;
300+ register double b = (*y - m5) * d;
301+ *x = a * m3 - b * m2;
302+ *y = b * m0 - a * m1;
303+ }
304+
305+ //------------------------------------------------------------------------
306+ inline double trans_affine::scale() const
307+ {
308+ double x = M_SQRT1_2 * m0 + M_SQRT1_2 * m2;
309+ double y = M_SQRT1_2 * m1 + M_SQRT1_2 * m3;
310+ return sqrt(x*x + y*y);
311+ }
312+
313+ //------------------------------------------------------------------------
314+ inline const trans_affine& trans_affine::premultiply(const trans_affine& m)
315+ {
316+ trans_affine t = m;
317+ return *this = t.multiply(*this);
318+ }
319+
320+ //------------------------------------------------------------------------
321+ inline const trans_affine& trans_affine::multiply_inv(const trans_affine& m)
322+ {
323+ trans_affine t = m;
324+ t.invert();
325+ multiply(t);
326+ return *this;
327+ }
328+
329+ //------------------------------------------------------------------------
330+ inline const trans_affine& trans_affine::premultiply_inv(const trans_affine& m)
331+ {
332+ trans_affine t = m;
333+ t.invert();
334+ return *this = t.multiply(*this);
335+ }
336+
337+ //====================================================trans_affine_rotation
338+ // Rotation matrix. sin() and cos() are calculated twice for the same angle.
339+ // There's no harm because the performance of sin()/cos() is very good on all
340+ // modern processors. Besides, this operation is not going to be invoked too
341+ // often.
342+ class trans_affine_rotation : public trans_affine
343+ {
344+ public:
345+ trans_affine_rotation(double a) :
346+ trans_affine(cos(a), sin(a), -sin(a), cos(a), 0.0, 0.0)
347+ {}
348+ };
349+
350+ //====================================================trans_affine_scaling
351+ // Scaling matrix. sx, sy - scale coefficients by X and Y respectively
352+ class trans_affine_scaling : public trans_affine
353+ {
354+ public:
355+ trans_affine_scaling(double sx, double sy) :
356+ trans_affine(sx, 0.0, 0.0, sy, 0.0, 0.0)
357+ {}
358+
359+ trans_affine_scaling(double s) :
360+ trans_affine(s, 0.0, 0.0, s, 0.0, 0.0)
361+ {}
362+ };
363+
364+ //================================================trans_affine_translation
365+ // Translation matrix
366+ class trans_affine_translation : public trans_affine
367+ {
368+ public:
369+ trans_affine_translation(double tx, double ty) :
370+ trans_affine(1.0, 0.0, 0.0, 1.0, tx, ty)
371+ {}
372+ };
373+
374+ //====================================================trans_affine_skewing
375+ // Sckewing (shear) matrix
376+ class trans_affine_skewing : public trans_affine
377+ {
378+ public:
379+ trans_affine_skewing(double sx, double sy) :
380+ trans_affine(1.0, tan(sy), tan(sx), 1.0, 0.0, 0.0)
381+ {}
382+ };
383+
384+
385+ //===============================================trans_affine_line_segment
386+ // Rotate, Scale and Translate, associating 0...dist with line segment
387+ // x1,y1,x2,y2
388+ class trans_affine_line_segment : public trans_affine
389+ {
390+ public:
391+ trans_affine_line_segment(double x1, double y1, double x2, double y2,
392+ double dist)
393+ {
394+ double dx = x2 - x1;
395+ double dy = y2 - y1;
396+ if(dist > 0.0)
397+ {
398+ multiply(trans_affine_scaling(sqrt(dx * dx + dy * dy) / dist));
399+ }
400+ multiply(trans_affine_rotation(atan2(dy, dx)));
401+ multiply(trans_affine_translation(x1, y1));
402+ }
403+ };
404+
405+
406+}
407+
408+
409+#endif
410+
1@@ -0,0 +1,603 @@
2+/* ftconfig.h. Generated from ftconfig.in by configure. */
3+/***************************************************************************/
4+/* */
5+/* ftconfig.in */
6+/* */
7+/* UNIX-specific configuration file (specification only). */
8+/* */
9+/* Copyright 1996-2018 by */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+
21+ /*************************************************************************/
22+ /* */
23+ /* This header file contains a number of macro definitions that are used */
24+ /* by the rest of the engine. Most of the macros here are automatically */
25+ /* determined at compile time, and you should not need to change it to */
26+ /* port FreeType, except to compile the library with a non-ANSI */
27+ /* compiler. */
28+ /* */
29+ /* Note however that if some specific modifications are needed, we */
30+ /* advise you to place a modified copy in your build directory. */
31+ /* */
32+ /* The build directory is usually `builds/<system>', and contains */
33+ /* system-specific files that are always included first when building */
34+ /* the library. */
35+ /* */
36+ /*************************************************************************/
37+
38+
39+#ifndef FTCONFIG_H_
40+#define FTCONFIG_H_
41+
42+#include <ft2build.h>
43+#include FT_CONFIG_OPTIONS_H
44+#include FT_CONFIG_STANDARD_LIBRARY_H
45+
46+
47+FT_BEGIN_HEADER
48+
49+
50+ /*************************************************************************/
51+ /* */
52+ /* PLATFORM-SPECIFIC CONFIGURATION MACROS */
53+ /* */
54+ /* These macros can be toggled to suit a specific system. The current */
55+ /* ones are defaults used to compile FreeType in an ANSI C environment */
56+ /* (16bit compilers are also supported). Copy this file to your own */
57+ /* `builds/<system>' directory, and edit it to port the engine. */
58+ /* */
59+ /*************************************************************************/
60+
61+
62+#define HAVE_UNISTD_H 1
63+#define HAVE_FCNTL_H 1
64+#define HAVE_STDINT_H 1
65+
66+
67+ /* There are systems (like the Texas Instruments 'C54x) where a `char' */
68+ /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */
69+ /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */
70+ /* is probably unexpected. */
71+ /* */
72+ /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */
73+ /* `char' type. */
74+
75+#ifndef FT_CHAR_BIT
76+#define FT_CHAR_BIT CHAR_BIT
77+#endif
78+
79+
80+/* #undef FT_USE_AUTOCONF_SIZEOF_TYPES */
81+#ifdef FT_USE_AUTOCONF_SIZEOF_TYPES
82+
83+#define SIZEOF_INT 4
84+#define SIZEOF_LONG 4
85+#define FT_SIZEOF_INT SIZEOF_INT
86+#define FT_SIZEOF_LONG SIZEOF_LONG
87+
88+#else /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
89+
90+ /* Following cpp computation of the bit length of int and long */
91+ /* is copied from default include/freetype/config/ftconfig.h. */
92+ /* If any improvement is required for this file, it should be */
93+ /* applied to the original header file for the builders that */
94+ /* do not use configure script. */
95+
96+ /* The size of an `int' type. */
97+#if FT_UINT_MAX == 0xFFFFUL
98+#define FT_SIZEOF_INT (16 / FT_CHAR_BIT)
99+#elif FT_UINT_MAX == 0xFFFFFFFFUL
100+#define FT_SIZEOF_INT (32 / FT_CHAR_BIT)
101+#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
102+#define FT_SIZEOF_INT (64 / FT_CHAR_BIT)
103+#else
104+#error "Unsupported size of `int' type!"
105+#endif
106+
107+ /* The size of a `long' type. A five-byte `long' (as used e.g. on the */
108+ /* DM642) is recognized but avoided. */
109+#if FT_ULONG_MAX == 0xFFFFFFFFUL
110+#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
111+#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
112+#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
113+#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
114+#define FT_SIZEOF_LONG (64 / FT_CHAR_BIT)
115+#else
116+#error "Unsupported size of `long' type!"
117+#endif
118+
119+#endif /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
120+
121+
122+ /* FT_UNUSED is a macro used to indicate that a given parameter is not */
123+ /* used -- this is only used to get rid of unpleasant compiler warnings */
124+#ifndef FT_UNUSED
125+#define FT_UNUSED( arg ) ( (arg) = (arg) )
126+#endif
127+
128+
129+ /*************************************************************************/
130+ /* */
131+ /* AUTOMATIC CONFIGURATION MACROS */
132+ /* */
133+ /* These macros are computed from the ones defined above. Don't touch */
134+ /* their definition, unless you know precisely what you are doing. No */
135+ /* porter should need to mess with them. */
136+ /* */
137+ /*************************************************************************/
138+
139+
140+ /*************************************************************************/
141+ /* */
142+ /* Mac support */
143+ /* */
144+ /* This is the only necessary change, so it is defined here instead */
145+ /* providing a new configuration file. */
146+ /* */
147+#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
148+ /* no Carbon frameworks for 64bit 10.4.x */
149+ /* AvailabilityMacros.h is available since Mac OS X 10.2, */
150+ /* so guess the system version by maximum errno before inclusion */
151+#include <errno.h>
152+#ifdef ECANCELED /* defined since 10.2 */
153+#include "AvailabilityMacros.h"
154+#endif
155+#if defined( __LP64__ ) && \
156+ ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
157+#undef FT_MACINTOSH
158+#endif
159+
160+#elif defined( __SC__ ) || defined( __MRC__ )
161+ /* Classic MacOS compilers */
162+#include "ConditionalMacros.h"
163+#if TARGET_OS_MAC
164+#define FT_MACINTOSH 1
165+#endif
166+
167+#endif
168+
169+
170+ /* Fix compiler warning with sgi compiler */
171+#if defined( __sgi ) && !defined( __GNUC__ )
172+#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
173+#pragma set woff 3505
174+#endif
175+#endif
176+
177+
178+ /*************************************************************************/
179+ /* */
180+ /* <Section> */
181+ /* basic_types */
182+ /* */
183+ /*************************************************************************/
184+
185+
186+ /*************************************************************************/
187+ /* */
188+ /* <Type> */
189+ /* FT_Int16 */
190+ /* */
191+ /* <Description> */
192+ /* A typedef for a 16bit signed integer type. */
193+ /* */
194+ typedef signed short FT_Int16;
195+
196+
197+ /*************************************************************************/
198+ /* */
199+ /* <Type> */
200+ /* FT_UInt16 */
201+ /* */
202+ /* <Description> */
203+ /* A typedef for a 16bit unsigned integer type. */
204+ /* */
205+ typedef unsigned short FT_UInt16;
206+
207+ /* */
208+
209+
210+ /* this #if 0 ... #endif clause is for documentation purposes */
211+#if 0
212+
213+ /*************************************************************************/
214+ /* */
215+ /* <Type> */
216+ /* FT_Int32 */
217+ /* */
218+ /* <Description> */
219+ /* A typedef for a 32bit signed integer type. The size depends on */
220+ /* the configuration. */
221+ /* */
222+ typedef signed XXX FT_Int32;
223+
224+
225+ /*************************************************************************/
226+ /* */
227+ /* <Type> */
228+ /* FT_UInt32 */
229+ /* */
230+ /* A typedef for a 32bit unsigned integer type. The size depends on */
231+ /* the configuration. */
232+ /* */
233+ typedef unsigned XXX FT_UInt32;
234+
235+
236+ /*************************************************************************/
237+ /* */
238+ /* <Type> */
239+ /* FT_Int64 */
240+ /* */
241+ /* A typedef for a 64bit signed integer type. The size depends on */
242+ /* the configuration. Only defined if there is real 64bit support; */
243+ /* otherwise, it gets emulated with a structure (if necessary). */
244+ /* */
245+ typedef signed XXX FT_Int64;
246+
247+
248+ /*************************************************************************/
249+ /* */
250+ /* <Type> */
251+ /* FT_UInt64 */
252+ /* */
253+ /* A typedef for a 64bit unsigned integer type. The size depends on */
254+ /* the configuration. Only defined if there is real 64bit support; */
255+ /* otherwise, it gets emulated with a structure (if necessary). */
256+ /* */
257+ typedef unsigned XXX FT_UInt64;
258+
259+ /* */
260+
261+#endif
262+
263+#if FT_SIZEOF_INT == 4
264+
265+ typedef signed int FT_Int32;
266+ typedef unsigned int FT_UInt32;
267+
268+#elif FT_SIZEOF_LONG == 4
269+
270+ typedef signed long FT_Int32;
271+ typedef unsigned long FT_UInt32;
272+
273+#else
274+#error "no 32bit type found -- please check your configuration files"
275+#endif
276+
277+
278+ /* look up an integer type that is at least 32 bits */
279+#if FT_SIZEOF_INT >= 4
280+
281+ typedef int FT_Fast;
282+ typedef unsigned int FT_UFast;
283+
284+#elif FT_SIZEOF_LONG >= 4
285+
286+ typedef long FT_Fast;
287+ typedef unsigned long FT_UFast;
288+
289+#endif
290+
291+
292+ /* determine whether we have a 64-bit int type */
293+ /* (mostly for environments without `autoconf') */
294+#if FT_SIZEOF_LONG == 8
295+
296+ /* FT_LONG64 must be defined if a 64-bit type is available */
297+#define FT_LONG64
298+#define FT_INT64 long
299+#define FT_UINT64 unsigned long
300+
301+ /* we handle the LLP64 scheme separately for GCC and clang, */
302+ /* suppressing the `long long' warning */
303+#elif ( FT_SIZEOF_LONG == 4 ) && \
304+ defined( HAVE_LONG_LONG_INT ) && \
305+ defined( __GNUC__ )
306+#pragma GCC diagnostic ignored "-Wlong-long"
307+#define FT_LONG64
308+#define FT_INT64 long long int
309+#define FT_UINT64 unsigned long long int
310+
311+ /*************************************************************************/
312+ /* */
313+ /* A 64-bit data type may create compilation problems if you compile */
314+ /* in strict ANSI mode. To avoid them, we disable other 64-bit data */
315+ /* types if __STDC__ is defined. You can however ignore this rule */
316+ /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
317+ /* */
318+#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
319+
320+#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
321+
322+#define FT_LONG64
323+#define FT_INT64 long long int
324+#define FT_UINT64 unsigned long long int
325+
326+#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
327+
328+ /* this compiler provides the __int64 type */
329+#define FT_LONG64
330+#define FT_INT64 __int64
331+#define FT_UINT64 unsigned __int64
332+
333+#elif defined( __BORLANDC__ ) /* Borland C++ */
334+
335+ /* XXXX: We should probably check the value of __BORLANDC__ in order */
336+ /* to test the compiler version. */
337+
338+ /* this compiler provides the __int64 type */
339+#define FT_LONG64
340+#define FT_INT64 __int64
341+#define FT_UINT64 unsigned __int64
342+
343+#elif defined( __WATCOMC__ ) /* Watcom C++ */
344+
345+ /* Watcom doesn't provide 64-bit data types */
346+
347+#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
348+
349+#define FT_LONG64
350+#define FT_INT64 long long int
351+#define FT_UINT64 unsigned long long int
352+
353+#elif defined( __GNUC__ )
354+
355+ /* GCC provides the `long long' type */
356+#define FT_LONG64
357+#define FT_INT64 long long int
358+#define FT_UINT64 unsigned long long int
359+
360+#endif /* __STDC_VERSION__ >= 199901L */
361+
362+#endif /* FT_SIZEOF_LONG == 8 */
363+
364+#ifdef FT_LONG64
365+ typedef FT_INT64 FT_Int64;
366+ typedef FT_UINT64 FT_UInt64;
367+#endif
368+
369+
370+#ifdef _WIN64
371+ /* only 64bit Windows uses the LLP64 data model, i.e., */
372+ /* 32bit integers, 64bit pointers */
373+#define FT_UINT_TO_POINTER( x ) (void*)(unsigned __int64)(x)
374+#else
375+#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
376+#endif
377+
378+
379+ /*************************************************************************/
380+ /* */
381+ /* miscellaneous */
382+ /* */
383+ /*************************************************************************/
384+
385+
386+#define FT_BEGIN_STMNT do {
387+#define FT_END_STMNT } while ( 0 )
388+#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
389+
390+
391+ /* typeof condition taken from gnulib's `intprops.h' header file */
392+#if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \
393+ ( defined( __IBMC__ ) && __IBMC__ >= 1210 && \
394+ defined( __IBM__TYPEOF__ ) ) || \
395+ ( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) )
396+#define FT_TYPEOF( type ) ( __typeof__ ( type ) )
397+#else
398+#define FT_TYPEOF( type ) /* empty */
399+#endif
400+
401+
402+ /* Use FT_LOCAL and FT_LOCAL_DEF to declare and define, respectively, */
403+ /* a function that gets used only within the scope of a module. */
404+ /* Normally, both the header and source code files for such a */
405+ /* function are within a single module directory. */
406+ /* */
407+ /* Intra-module arrays should be tagged with FT_LOCAL_ARRAY and */
408+ /* FT_LOCAL_ARRAY_DEF. */
409+ /* */
410+#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
411+
412+#define FT_LOCAL( x ) static x
413+#define FT_LOCAL_DEF( x ) static x
414+
415+#else
416+
417+#ifdef __cplusplus
418+#define FT_LOCAL( x ) extern "C" x
419+#define FT_LOCAL_DEF( x ) extern "C" x
420+#else
421+#define FT_LOCAL( x ) extern x
422+#define FT_LOCAL_DEF( x ) x
423+#endif
424+
425+#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
426+
427+#define FT_LOCAL_ARRAY( x ) extern const x
428+#define FT_LOCAL_ARRAY_DEF( x ) const x
429+
430+
431+ /* Use FT_BASE and FT_BASE_DEF to declare and define, respectively, */
432+ /* functions that are used in more than a single module. In the */
433+ /* current setup this implies that the declaration is in a header */
434+ /* file in the `include/freetype/internal' directory, and the */
435+ /* function body is in a file in `src/base'. */
436+ /* */
437+#ifndef FT_BASE
438+
439+#ifdef __cplusplus
440+#define FT_BASE( x ) extern "C" x
441+#else
442+#define FT_BASE( x ) extern x
443+#endif
444+
445+#endif /* !FT_BASE */
446+
447+
448+#ifndef FT_BASE_DEF
449+
450+#ifdef __cplusplus
451+#define FT_BASE_DEF( x ) x
452+#else
453+#define FT_BASE_DEF( x ) x
454+#endif
455+
456+#endif /* !FT_BASE_DEF */
457+
458+
459+ /* When compiling FreeType as a DLL or DSO with hidden visibility */
460+ /* some systems/compilers need a special attribute in front OR after */
461+ /* the return type of function declarations. */
462+ /* */
463+ /* Two macros are used within the FreeType source code to define */
464+ /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
465+ /* */
466+ /* FT_EXPORT( return_type ) */
467+ /* */
468+ /* is used in a function declaration, as in */
469+ /* */
470+ /* FT_EXPORT( FT_Error ) */
471+ /* FT_Init_FreeType( FT_Library* alibrary ); */
472+ /* */
473+ /* */
474+ /* FT_EXPORT_DEF( return_type ) */
475+ /* */
476+ /* is used in a function definition, as in */
477+ /* */
478+ /* FT_EXPORT_DEF( FT_Error ) */
479+ /* FT_Init_FreeType( FT_Library* alibrary ) */
480+ /* { */
481+ /* ... some code ... */
482+ /* return FT_Err_Ok; */
483+ /* } */
484+ /* */
485+ /* You can provide your own implementation of FT_EXPORT and */
486+ /* FT_EXPORT_DEF here if you want. */
487+ /* */
488+ /* To export a variable, use FT_EXPORT_VAR. */
489+ /* */
490+#ifndef FT_EXPORT
491+
492+#ifdef FT2_BUILD_LIBRARY
493+
494+#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
495+#define FT_EXPORT( x ) __declspec( dllexport ) x
496+#elif defined( __GNUC__ ) && __GNUC__ >= 4
497+#define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
498+#elif defined( __cplusplus )
499+#define FT_EXPORT( x ) extern "C" x
500+#else
501+#define FT_EXPORT( x ) extern x
502+#endif
503+
504+#else
505+
506+#if defined( FT2_DLLIMPORT )
507+#define FT_EXPORT( x ) __declspec( dllimport ) x
508+#elif defined( __cplusplus )
509+#define FT_EXPORT( x ) extern "C" x
510+#else
511+#define FT_EXPORT( x ) extern x
512+#endif
513+
514+#endif
515+
516+#endif /* !FT_EXPORT */
517+
518+
519+#ifndef FT_EXPORT_DEF
520+
521+#ifdef __cplusplus
522+#define FT_EXPORT_DEF( x ) extern "C" x
523+#else
524+#define FT_EXPORT_DEF( x ) extern x
525+#endif
526+
527+#endif /* !FT_EXPORT_DEF */
528+
529+
530+#ifndef FT_EXPORT_VAR
531+
532+#ifdef __cplusplus
533+#define FT_EXPORT_VAR( x ) extern "C" x
534+#else
535+#define FT_EXPORT_VAR( x ) extern x
536+#endif
537+
538+#endif /* !FT_EXPORT_VAR */
539+
540+ /* The following macros are needed to compile the library with a */
541+ /* C++ compiler and with 16bit compilers. */
542+ /* */
543+
544+ /* This is special. Within C++, you must specify `extern "C"' for */
545+ /* functions which are used via function pointers, and you also */
546+ /* must do that for structures which contain function pointers to */
547+ /* assure C linkage -- it's not possible to have (local) anonymous */
548+ /* functions which are accessed by (global) function pointers. */
549+ /* */
550+ /* */
551+ /* FT_CALLBACK_DEF is used to _define_ a callback function, */
552+ /* located in the same source code file as the structure that uses */
553+ /* it. */
554+ /* */
555+ /* FT_BASE_CALLBACK and FT_BASE_CALLBACK_DEF are used to declare */
556+ /* and define a callback function, respectively, in a similar way */
557+ /* as FT_BASE and FT_BASE_DEF work. */
558+ /* */
559+ /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
560+ /* contains pointers to callback functions. */
561+ /* */
562+ /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
563+ /* that contains pointers to callback functions. */
564+ /* */
565+ /* */
566+ /* Some 16bit compilers have to redefine these macros to insert */
567+ /* the infamous `_cdecl' or `__fastcall' declarations. */
568+ /* */
569+#ifndef FT_CALLBACK_DEF
570+#ifdef __cplusplus
571+#define FT_CALLBACK_DEF( x ) extern "C" x
572+#else
573+#define FT_CALLBACK_DEF( x ) static x
574+#endif
575+#endif /* FT_CALLBACK_DEF */
576+
577+#ifndef FT_BASE_CALLBACK
578+#ifdef __cplusplus
579+#define FT_BASE_CALLBACK( x ) extern "C" x
580+#define FT_BASE_CALLBACK_DEF( x ) extern "C" x
581+#else
582+#define FT_BASE_CALLBACK( x ) extern x
583+#define FT_BASE_CALLBACK_DEF( x ) x
584+#endif
585+#endif /* FT_BASE_CALLBACK */
586+
587+#ifndef FT_CALLBACK_TABLE
588+#ifdef __cplusplus
589+#define FT_CALLBACK_TABLE extern "C"
590+#define FT_CALLBACK_TABLE_DEF extern "C"
591+#else
592+#define FT_CALLBACK_TABLE extern
593+#define FT_CALLBACK_TABLE_DEF /* nothing */
594+#endif
595+#endif /* FT_CALLBACK_TABLE */
596+
597+
598+FT_END_HEADER
599+
600+
601+#endif /* FTCONFIG_H_ */
602+
603+
604+/* END */
1@@ -0,0 +1,804 @@
2+/***************************************************************************/
3+/* */
4+/* ftheader.h */
5+/* */
6+/* Build macros of the FreeType 2 library. */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+#ifndef FTHEADER_H_
20+#define FTHEADER_H_
21+
22+
23+ /*@***********************************************************************/
24+ /* */
25+ /* <Macro> */
26+ /* FT_BEGIN_HEADER */
27+ /* */
28+ /* <Description> */
29+ /* This macro is used in association with @FT_END_HEADER in header */
30+ /* files to ensure that the declarations within are properly */
31+ /* encapsulated in an `extern "C" { .. }' block when included from a */
32+ /* C++ compiler. */
33+ /* */
34+#ifdef __cplusplus
35+#define FT_BEGIN_HEADER extern "C" {
36+#else
37+#define FT_BEGIN_HEADER /* nothing */
38+#endif
39+
40+
41+ /*@***********************************************************************/
42+ /* */
43+ /* <Macro> */
44+ /* FT_END_HEADER */
45+ /* */
46+ /* <Description> */
47+ /* This macro is used in association with @FT_BEGIN_HEADER in header */
48+ /* files to ensure that the declarations within are properly */
49+ /* encapsulated in an `extern "C" { .. }' block when included from a */
50+ /* C++ compiler. */
51+ /* */
52+#ifdef __cplusplus
53+#define FT_END_HEADER }
54+#else
55+#define FT_END_HEADER /* nothing */
56+#endif
57+
58+
59+ /*************************************************************************/
60+ /* */
61+ /* Aliases for the FreeType 2 public and configuration files. */
62+ /* */
63+ /*************************************************************************/
64+
65+ /*************************************************************************/
66+ /* */
67+ /* <Section> */
68+ /* header_file_macros */
69+ /* */
70+ /* <Title> */
71+ /* Header File Macros */
72+ /* */
73+ /* <Abstract> */
74+ /* Macro definitions used to #include specific header files. */
75+ /* */
76+ /* <Description> */
77+ /* The following macros are defined to the name of specific */
78+ /* FreeType~2 header files. They can be used directly in #include */
79+ /* statements as in: */
80+ /* */
81+ /* { */
82+ /* #include FT_FREETYPE_H */
83+ /* #include FT_MULTIPLE_MASTERS_H */
84+ /* #include FT_GLYPH_H */
85+ /* } */
86+ /* */
87+ /* There are several reasons why we are now using macros to name */
88+ /* public header files. The first one is that such macros are not */
89+ /* limited to the infamous 8.3~naming rule required by DOS (and */
90+ /* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */
91+ /* */
92+ /* The second reason is that it allows for more flexibility in the */
93+ /* way FreeType~2 is installed on a given system. */
94+ /* */
95+ /*************************************************************************/
96+
97+
98+ /* configuration files */
99+
100+ /*************************************************************************
101+ *
102+ * @macro:
103+ * FT_CONFIG_CONFIG_H
104+ *
105+ * @description:
106+ * A macro used in #include statements to name the file containing
107+ * FreeType~2 configuration data.
108+ *
109+ */
110+#ifndef FT_CONFIG_CONFIG_H
111+#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h>
112+#endif
113+
114+
115+ /*************************************************************************
116+ *
117+ * @macro:
118+ * FT_CONFIG_STANDARD_LIBRARY_H
119+ *
120+ * @description:
121+ * A macro used in #include statements to name the file containing
122+ * FreeType~2 interface to the standard C library functions.
123+ *
124+ */
125+#ifndef FT_CONFIG_STANDARD_LIBRARY_H
126+#define FT_CONFIG_STANDARD_LIBRARY_H <freetype/config/ftstdlib.h>
127+#endif
128+
129+
130+ /*************************************************************************
131+ *
132+ * @macro:
133+ * FT_CONFIG_OPTIONS_H
134+ *
135+ * @description:
136+ * A macro used in #include statements to name the file containing
137+ * FreeType~2 project-specific configuration options.
138+ *
139+ */
140+#ifndef FT_CONFIG_OPTIONS_H
141+#define FT_CONFIG_OPTIONS_H <freetype/config/ftoption.h>
142+#endif
143+
144+
145+ /*************************************************************************
146+ *
147+ * @macro:
148+ * FT_CONFIG_MODULES_H
149+ *
150+ * @description:
151+ * A macro used in #include statements to name the file containing the
152+ * list of FreeType~2 modules that are statically linked to new library
153+ * instances in @FT_Init_FreeType.
154+ *
155+ */
156+#ifndef FT_CONFIG_MODULES_H
157+#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h>
158+#endif
159+
160+ /* */
161+
162+ /* public headers */
163+
164+ /*************************************************************************
165+ *
166+ * @macro:
167+ * FT_FREETYPE_H
168+ *
169+ * @description:
170+ * A macro used in #include statements to name the file containing the
171+ * base FreeType~2 API.
172+ *
173+ */
174+#define FT_FREETYPE_H <freetype/freetype.h>
175+
176+
177+ /*************************************************************************
178+ *
179+ * @macro:
180+ * FT_ERRORS_H
181+ *
182+ * @description:
183+ * A macro used in #include statements to name the file containing the
184+ * list of FreeType~2 error codes (and messages).
185+ *
186+ * It is included by @FT_FREETYPE_H.
187+ *
188+ */
189+#define FT_ERRORS_H <freetype/fterrors.h>
190+
191+
192+ /*************************************************************************
193+ *
194+ * @macro:
195+ * FT_MODULE_ERRORS_H
196+ *
197+ * @description:
198+ * A macro used in #include statements to name the file containing the
199+ * list of FreeType~2 module error offsets (and messages).
200+ *
201+ */
202+#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h>
203+
204+
205+ /*************************************************************************
206+ *
207+ * @macro:
208+ * FT_SYSTEM_H
209+ *
210+ * @description:
211+ * A macro used in #include statements to name the file containing the
212+ * FreeType~2 interface to low-level operations (i.e., memory management
213+ * and stream i/o).
214+ *
215+ * It is included by @FT_FREETYPE_H.
216+ *
217+ */
218+#define FT_SYSTEM_H <freetype/ftsystem.h>
219+
220+
221+ /*************************************************************************
222+ *
223+ * @macro:
224+ * FT_IMAGE_H
225+ *
226+ * @description:
227+ * A macro used in #include statements to name the file containing type
228+ * definitions related to glyph images (i.e., bitmaps, outlines,
229+ * scan-converter parameters).
230+ *
231+ * It is included by @FT_FREETYPE_H.
232+ *
233+ */
234+#define FT_IMAGE_H <freetype/ftimage.h>
235+
236+
237+ /*************************************************************************
238+ *
239+ * @macro:
240+ * FT_TYPES_H
241+ *
242+ * @description:
243+ * A macro used in #include statements to name the file containing the
244+ * basic data types defined by FreeType~2.
245+ *
246+ * It is included by @FT_FREETYPE_H.
247+ *
248+ */
249+#define FT_TYPES_H <freetype/fttypes.h>
250+
251+
252+ /*************************************************************************
253+ *
254+ * @macro:
255+ * FT_LIST_H
256+ *
257+ * @description:
258+ * A macro used in #include statements to name the file containing the
259+ * list management API of FreeType~2.
260+ *
261+ * (Most applications will never need to include this file.)
262+ *
263+ */
264+#define FT_LIST_H <freetype/ftlist.h>
265+
266+
267+ /*************************************************************************
268+ *
269+ * @macro:
270+ * FT_OUTLINE_H
271+ *
272+ * @description:
273+ * A macro used in #include statements to name the file containing the
274+ * scalable outline management API of FreeType~2.
275+ *
276+ */
277+#define FT_OUTLINE_H <freetype/ftoutln.h>
278+
279+
280+ /*************************************************************************
281+ *
282+ * @macro:
283+ * FT_SIZES_H
284+ *
285+ * @description:
286+ * A macro used in #include statements to name the file containing the
287+ * API which manages multiple @FT_Size objects per face.
288+ *
289+ */
290+#define FT_SIZES_H <freetype/ftsizes.h>
291+
292+
293+ /*************************************************************************
294+ *
295+ * @macro:
296+ * FT_MODULE_H
297+ *
298+ * @description:
299+ * A macro used in #include statements to name the file containing the
300+ * module management API of FreeType~2.
301+ *
302+ */
303+#define FT_MODULE_H <freetype/ftmodapi.h>
304+
305+
306+ /*************************************************************************
307+ *
308+ * @macro:
309+ * FT_RENDER_H
310+ *
311+ * @description:
312+ * A macro used in #include statements to name the file containing the
313+ * renderer module management API of FreeType~2.
314+ *
315+ */
316+#define FT_RENDER_H <freetype/ftrender.h>
317+
318+
319+ /*************************************************************************
320+ *
321+ * @macro:
322+ * FT_DRIVER_H
323+ *
324+ * @description:
325+ * A macro used in #include statements to name the file containing
326+ * structures and macros related to the driver modules.
327+ *
328+ */
329+#define FT_DRIVER_H <freetype/ftdriver.h>
330+
331+
332+ /*************************************************************************
333+ *
334+ * @macro:
335+ * FT_AUTOHINTER_H
336+ *
337+ * @description:
338+ * A macro used in #include statements to name the file containing
339+ * structures and macros related to the auto-hinting module.
340+ *
341+ * Deprecated since version 2.9; use @FT_DRIVER_H instead.
342+ *
343+ */
344+#define FT_AUTOHINTER_H FT_DRIVER_H
345+
346+
347+ /*************************************************************************
348+ *
349+ * @macro:
350+ * FT_CFF_DRIVER_H
351+ *
352+ * @description:
353+ * A macro used in #include statements to name the file containing
354+ * structures and macros related to the CFF driver module.
355+ *
356+ * Deprecated since version 2.9; use @FT_DRIVER_H instead.
357+ *
358+ */
359+#define FT_CFF_DRIVER_H FT_DRIVER_H
360+
361+
362+ /*************************************************************************
363+ *
364+ * @macro:
365+ * FT_TRUETYPE_DRIVER_H
366+ *
367+ * @description:
368+ * A macro used in #include statements to name the file containing
369+ * structures and macros related to the TrueType driver module.
370+ *
371+ * Deprecated since version 2.9; use @FT_DRIVER_H instead.
372+ *
373+ */
374+#define FT_TRUETYPE_DRIVER_H FT_DRIVER_H
375+
376+
377+ /*************************************************************************
378+ *
379+ * @macro:
380+ * FT_PCF_DRIVER_H
381+ *
382+ * @description:
383+ * A macro used in #include statements to name the file containing
384+ * structures and macros related to the PCF driver module.
385+ *
386+ * Deprecated since version 2.9; use @FT_DRIVER_H instead.
387+ *
388+ */
389+#define FT_PCF_DRIVER_H FT_DRIVER_H
390+
391+
392+ /*************************************************************************
393+ *
394+ * @macro:
395+ * FT_TYPE1_TABLES_H
396+ *
397+ * @description:
398+ * A macro used in #include statements to name the file containing the
399+ * types and API specific to the Type~1 format.
400+ *
401+ */
402+#define FT_TYPE1_TABLES_H <freetype/t1tables.h>
403+
404+
405+ /*************************************************************************
406+ *
407+ * @macro:
408+ * FT_TRUETYPE_IDS_H
409+ *
410+ * @description:
411+ * A macro used in #include statements to name the file containing the
412+ * enumeration values which identify name strings, languages, encodings,
413+ * etc. This file really contains a _large_ set of constant macro
414+ * definitions, taken from the TrueType and OpenType specifications.
415+ *
416+ */
417+#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h>
418+
419+
420+ /*************************************************************************
421+ *
422+ * @macro:
423+ * FT_TRUETYPE_TABLES_H
424+ *
425+ * @description:
426+ * A macro used in #include statements to name the file containing the
427+ * types and API specific to the TrueType (as well as OpenType) format.
428+ *
429+ */
430+#define FT_TRUETYPE_TABLES_H <freetype/tttables.h>
431+
432+
433+ /*************************************************************************
434+ *
435+ * @macro:
436+ * FT_TRUETYPE_TAGS_H
437+ *
438+ * @description:
439+ * A macro used in #include statements to name the file containing the
440+ * definitions of TrueType four-byte `tags' which identify blocks in
441+ * SFNT-based font formats (i.e., TrueType and OpenType).
442+ *
443+ */
444+#define FT_TRUETYPE_TAGS_H <freetype/tttags.h>
445+
446+
447+ /*************************************************************************
448+ *
449+ * @macro:
450+ * FT_BDF_H
451+ *
452+ * @description:
453+ * A macro used in #include statements to name the file containing the
454+ * definitions of an API which accesses BDF-specific strings from a
455+ * face.
456+ *
457+ */
458+#define FT_BDF_H <freetype/ftbdf.h>
459+
460+
461+ /*************************************************************************
462+ *
463+ * @macro:
464+ * FT_CID_H
465+ *
466+ * @description:
467+ * A macro used in #include statements to name the file containing the
468+ * definitions of an API which access CID font information from a
469+ * face.
470+ *
471+ */
472+#define FT_CID_H <freetype/ftcid.h>
473+
474+
475+ /*************************************************************************
476+ *
477+ * @macro:
478+ * FT_GZIP_H
479+ *
480+ * @description:
481+ * A macro used in #include statements to name the file containing the
482+ * definitions of an API which supports gzip-compressed files.
483+ *
484+ */
485+#define FT_GZIP_H <freetype/ftgzip.h>
486+
487+
488+ /*************************************************************************
489+ *
490+ * @macro:
491+ * FT_LZW_H
492+ *
493+ * @description:
494+ * A macro used in #include statements to name the file containing the
495+ * definitions of an API which supports LZW-compressed files.
496+ *
497+ */
498+#define FT_LZW_H <freetype/ftlzw.h>
499+
500+
501+ /*************************************************************************
502+ *
503+ * @macro:
504+ * FT_BZIP2_H
505+ *
506+ * @description:
507+ * A macro used in #include statements to name the file containing the
508+ * definitions of an API which supports bzip2-compressed files.
509+ *
510+ */
511+#define FT_BZIP2_H <freetype/ftbzip2.h>
512+
513+
514+ /*************************************************************************
515+ *
516+ * @macro:
517+ * FT_WINFONTS_H
518+ *
519+ * @description:
520+ * A macro used in #include statements to name the file containing the
521+ * definitions of an API which supports Windows FNT files.
522+ *
523+ */
524+#define FT_WINFONTS_H <freetype/ftwinfnt.h>
525+
526+
527+ /*************************************************************************
528+ *
529+ * @macro:
530+ * FT_GLYPH_H
531+ *
532+ * @description:
533+ * A macro used in #include statements to name the file containing the
534+ * API of the optional glyph management component.
535+ *
536+ */
537+#define FT_GLYPH_H <freetype/ftglyph.h>
538+
539+
540+ /*************************************************************************
541+ *
542+ * @macro:
543+ * FT_BITMAP_H
544+ *
545+ * @description:
546+ * A macro used in #include statements to name the file containing the
547+ * API of the optional bitmap conversion component.
548+ *
549+ */
550+#define FT_BITMAP_H <freetype/ftbitmap.h>
551+
552+
553+ /*************************************************************************
554+ *
555+ * @macro:
556+ * FT_BBOX_H
557+ *
558+ * @description:
559+ * A macro used in #include statements to name the file containing the
560+ * API of the optional exact bounding box computation routines.
561+ *
562+ */
563+#define FT_BBOX_H <freetype/ftbbox.h>
564+
565+
566+ /*************************************************************************
567+ *
568+ * @macro:
569+ * FT_CACHE_H
570+ *
571+ * @description:
572+ * A macro used in #include statements to name the file containing the
573+ * API of the optional FreeType~2 cache sub-system.
574+ *
575+ */
576+#define FT_CACHE_H <freetype/ftcache.h>
577+
578+
579+ /*************************************************************************
580+ *
581+ * @macro:
582+ * FT_MAC_H
583+ *
584+ * @description:
585+ * A macro used in #include statements to name the file containing the
586+ * Macintosh-specific FreeType~2 API. The latter is used to access
587+ * fonts embedded in resource forks.
588+ *
589+ * This header file must be explicitly included by client applications
590+ * compiled on the Mac (note that the base API still works though).
591+ *
592+ */
593+#define FT_MAC_H <freetype/ftmac.h>
594+
595+
596+ /*************************************************************************
597+ *
598+ * @macro:
599+ * FT_MULTIPLE_MASTERS_H
600+ *
601+ * @description:
602+ * A macro used in #include statements to name the file containing the
603+ * optional multiple-masters management API of FreeType~2.
604+ *
605+ */
606+#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h>
607+
608+
609+ /*************************************************************************
610+ *
611+ * @macro:
612+ * FT_SFNT_NAMES_H
613+ *
614+ * @description:
615+ * A macro used in #include statements to name the file containing the
616+ * optional FreeType~2 API which accesses embedded `name' strings in
617+ * SFNT-based font formats (i.e., TrueType and OpenType).
618+ *
619+ */
620+#define FT_SFNT_NAMES_H <freetype/ftsnames.h>
621+
622+
623+ /*************************************************************************
624+ *
625+ * @macro:
626+ * FT_OPENTYPE_VALIDATE_H
627+ *
628+ * @description:
629+ * A macro used in #include statements to name the file containing the
630+ * optional FreeType~2 API which validates OpenType tables (BASE, GDEF,
631+ * GPOS, GSUB, JSTF).
632+ *
633+ */
634+#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h>
635+
636+
637+ /*************************************************************************
638+ *
639+ * @macro:
640+ * FT_GX_VALIDATE_H
641+ *
642+ * @description:
643+ * A macro used in #include statements to name the file containing the
644+ * optional FreeType~2 API which validates TrueTypeGX/AAT tables (feat,
645+ * mort, morx, bsln, just, kern, opbd, trak, prop).
646+ *
647+ */
648+#define FT_GX_VALIDATE_H <freetype/ftgxval.h>
649+
650+
651+ /*************************************************************************
652+ *
653+ * @macro:
654+ * FT_PFR_H
655+ *
656+ * @description:
657+ * A macro used in #include statements to name the file containing the
658+ * FreeType~2 API which accesses PFR-specific data.
659+ *
660+ */
661+#define FT_PFR_H <freetype/ftpfr.h>
662+
663+
664+ /*************************************************************************
665+ *
666+ * @macro:
667+ * FT_STROKER_H
668+ *
669+ * @description:
670+ * A macro used in #include statements to name the file containing the
671+ * FreeType~2 API which provides functions to stroke outline paths.
672+ */
673+#define FT_STROKER_H <freetype/ftstroke.h>
674+
675+
676+ /*************************************************************************
677+ *
678+ * @macro:
679+ * FT_SYNTHESIS_H
680+ *
681+ * @description:
682+ * A macro used in #include statements to name the file containing the
683+ * FreeType~2 API which performs artificial obliquing and emboldening.
684+ */
685+#define FT_SYNTHESIS_H <freetype/ftsynth.h>
686+
687+
688+ /*************************************************************************
689+ *
690+ * @macro:
691+ * FT_FONT_FORMATS_H
692+ *
693+ * @description:
694+ * A macro used in #include statements to name the file containing the
695+ * FreeType~2 API which provides functions specific to font formats.
696+ */
697+#define FT_FONT_FORMATS_H <freetype/ftfntfmt.h>
698+
699+ /* deprecated */
700+#define FT_XFREE86_H FT_FONT_FORMATS_H
701+
702+
703+ /*************************************************************************
704+ *
705+ * @macro:
706+ * FT_TRIGONOMETRY_H
707+ *
708+ * @description:
709+ * A macro used in #include statements to name the file containing the
710+ * FreeType~2 API which performs trigonometric computations (e.g.,
711+ * cosines and arc tangents).
712+ */
713+#define FT_TRIGONOMETRY_H <freetype/fttrigon.h>
714+
715+
716+ /*************************************************************************
717+ *
718+ * @macro:
719+ * FT_LCD_FILTER_H
720+ *
721+ * @description:
722+ * A macro used in #include statements to name the file containing the
723+ * FreeType~2 API which performs color filtering for subpixel rendering.
724+ */
725+#define FT_LCD_FILTER_H <freetype/ftlcdfil.h>
726+
727+
728+ /*************************************************************************
729+ *
730+ * @macro:
731+ * FT_INCREMENTAL_H
732+ *
733+ * @description:
734+ * A macro used in #include statements to name the file containing the
735+ * FreeType~2 API which performs incremental glyph loading.
736+ */
737+#define FT_INCREMENTAL_H <freetype/ftincrem.h>
738+
739+
740+ /*************************************************************************
741+ *
742+ * @macro:
743+ * FT_GASP_H
744+ *
745+ * @description:
746+ * A macro used in #include statements to name the file containing the
747+ * FreeType~2 API which returns entries from the TrueType GASP table.
748+ */
749+#define FT_GASP_H <freetype/ftgasp.h>
750+
751+
752+ /*************************************************************************
753+ *
754+ * @macro:
755+ * FT_ADVANCES_H
756+ *
757+ * @description:
758+ * A macro used in #include statements to name the file containing the
759+ * FreeType~2 API which returns individual and ranged glyph advances.
760+ */
761+#define FT_ADVANCES_H <freetype/ftadvanc.h>
762+
763+
764+ /* */
765+
766+ /* These header files don't need to be included by the user. */
767+#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h>
768+#define FT_PARAMETER_TAGS_H <freetype/ftparams.h>
769+
770+ /* Deprecated macros. */
771+#define FT_UNPATENTED_HINTING_H <freetype/ftparams.h>
772+#define FT_TRUETYPE_UNPATENTED_H <freetype/ftparams.h>
773+
774+ /* FT_CACHE_H is the only header file needed for the cache subsystem. */
775+#define FT_CACHE_IMAGE_H FT_CACHE_H
776+#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H
777+#define FT_CACHE_CHARMAP_H FT_CACHE_H
778+
779+ /* The internals of the cache sub-system are no longer exposed. We */
780+ /* default to FT_CACHE_H at the moment just in case, but we know of */
781+ /* no rogue client that uses them. */
782+ /* */
783+#define FT_CACHE_MANAGER_H FT_CACHE_H
784+#define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H
785+#define FT_CACHE_INTERNAL_MANAGER_H FT_CACHE_H
786+#define FT_CACHE_INTERNAL_CACHE_H FT_CACHE_H
787+#define FT_CACHE_INTERNAL_GLYPH_H FT_CACHE_H
788+#define FT_CACHE_INTERNAL_IMAGE_H FT_CACHE_H
789+#define FT_CACHE_INTERNAL_SBITS_H FT_CACHE_H
790+
791+
792+ /*
793+ * Include internal headers definitions from <internal/...>
794+ * only when building the library.
795+ */
796+#ifdef FT2_BUILD_LIBRARY
797+#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h>
798+#include FT_INTERNAL_INTERNAL_H
799+#endif /* FT2_BUILD_LIBRARY */
800+
801+
802+#endif /* FTHEADER_H_ */
803+
804+
805+/* END */
1@@ -0,0 +1,22 @@
2+/* This is a generated file. */
3+FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
4+FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
5+FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
6+FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
7+FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
8+FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
9+FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
10+FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
11+FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
12+FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
13+FT_USE_MODULE( FT_Module_Class, autofit_module_class )
14+FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
15+FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
16+FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
17+FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
18+FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class )
19+FT_USE_MODULE( FT_Module_Class, gxv_module_class )
20+FT_USE_MODULE( FT_Module_Class, otv_module_class )
21+FT_USE_MODULE( FT_Module_Class, psaux_module_class )
22+FT_USE_MODULE( FT_Module_Class, psnames_module_class )
23+/* EOF */
1@@ -0,0 +1,977 @@
2+/***************************************************************************/
3+/* */
4+/* ftoption.h */
5+/* */
6+/* User-selectable configuration macros (specification only). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTOPTION_H_
21+#define FTOPTION_H_
22+
23+
24+#include <ft2build.h>
25+
26+
27+FT_BEGIN_HEADER
28+
29+ /*************************************************************************/
30+ /* */
31+ /* USER-SELECTABLE CONFIGURATION MACROS */
32+ /* */
33+ /* This file contains the default configuration macro definitions for */
34+ /* a standard build of the FreeType library. There are three ways to */
35+ /* use this file to build project-specific versions of the library: */
36+ /* */
37+ /* - You can modify this file by hand, but this is not recommended in */
38+ /* cases where you would like to build several versions of the */
39+ /* library from a single source directory. */
40+ /* */
41+ /* - You can put a copy of this file in your build directory, more */
42+ /* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */
43+ /* is the name of a directory that is included _before_ the FreeType */
44+ /* include path during compilation. */
45+ /* */
46+ /* The default FreeType Makefiles and Jamfiles use the build */
47+ /* directory `builds/<system>' by default, but you can easily change */
48+ /* that for your own projects. */
49+ /* */
50+ /* - Copy the file <ft2build.h> to `$BUILD/ft2build.h' and modify it */
51+ /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */
52+ /* locate this file during the build. For example, */
53+ /* */
54+ /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */
55+ /* #include <freetype/config/ftheader.h> */
56+ /* */
57+ /* will use `$BUILD/myftoptions.h' instead of this file for macro */
58+ /* definitions. */
59+ /* */
60+ /* Note also that you can similarly pre-define the macro */
61+ /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */
62+ /* that are statically linked to the library at compile time. By */
63+ /* default, this file is <freetype/config/ftmodule.h>. */
64+ /* */
65+ /* We highly recommend using the third method whenever possible. */
66+ /* */
67+ /*************************************************************************/
68+
69+
70+ /*************************************************************************/
71+ /*************************************************************************/
72+ /**** ****/
73+ /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/
74+ /**** ****/
75+ /*************************************************************************/
76+ /*************************************************************************/
77+
78+
79+ /*#***********************************************************************/
80+ /* */
81+ /* If you enable this configuration option, FreeType recognizes an */
82+ /* environment variable called `FREETYPE_PROPERTIES', which can be used */
83+ /* to control the various font drivers and modules. The controllable */
84+ /* properties are listed in the section @properties. */
85+ /* */
86+ /* You have to undefine this configuration option on platforms that lack */
87+ /* the concept of environment variables (and thus don't have the */
88+ /* `getenv' function), for example Windows CE. */
89+ /* */
90+ /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */
91+ /* multiple lines for better readability). */
92+ /* */
93+ /* { */
94+ /* <optional whitespace> */
95+ /* <module-name1> ':' */
96+ /* <property-name1> '=' <property-value1> */
97+ /* <whitespace> */
98+ /* <module-name2> ':' */
99+ /* <property-name2> '=' <property-value2> */
100+ /* ... */
101+ /* } */
102+ /* */
103+ /* Example: */
104+ /* */
105+ /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */
106+ /* cff:no-stem-darkening=1 \ */
107+ /* autofitter:warping=1 */
108+ /* */
109+#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
110+
111+
112+ /*************************************************************************/
113+ /* */
114+ /* Uncomment the line below if you want to activate LCD rendering */
115+ /* technology similar to ClearType in this build of the library. This */
116+ /* technology triples the resolution in the direction color subpixels. */
117+ /* To mitigate color fringes inherent to this technology, you also need */
118+ /* to explicitly set up LCD filtering. */
119+ /* */
120+ /* Note that this feature is covered by several Microsoft patents */
121+ /* and should not be activated in any default build of the library. */
122+ /* When this macro is not defined, FreeType offers alternative LCD */
123+ /* rendering technology that produces excellent output without LCD */
124+ /* filtering. */
125+ /* */
126+/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
127+
128+
129+ /*************************************************************************/
130+ /* */
131+ /* Many compilers provide a non-ANSI 64-bit data type that can be used */
132+ /* by FreeType to speed up some computations. However, this will create */
133+ /* some problems when compiling the library in strict ANSI mode. */
134+ /* */
135+ /* For this reason, the use of 64-bit integers is normally disabled when */
136+ /* the __STDC__ macro is defined. You can however disable this by */
137+ /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */
138+ /* */
139+ /* For most compilers, this will only create compilation warnings when */
140+ /* building the library. */
141+ /* */
142+ /* ObNote: The compiler-specific 64-bit integers are detected in the */
143+ /* file `ftconfig.h' either statically or through the */
144+ /* `configure' script on supported platforms. */
145+ /* */
146+#undef FT_CONFIG_OPTION_FORCE_INT64
147+
148+
149+ /*************************************************************************/
150+ /* */
151+ /* If this macro is defined, do not try to use an assembler version of */
152+ /* performance-critical functions (e.g. FT_MulFix). You should only do */
153+ /* that to verify that the assembler function works properly, or to */
154+ /* execute benchmark tests of the various implementations. */
155+/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */
156+
157+
158+ /*************************************************************************/
159+ /* */
160+ /* If this macro is defined, try to use an inlined assembler version of */
161+ /* the `FT_MulFix' function, which is a `hotspot' when loading and */
162+ /* hinting glyphs, and which should be executed as fast as possible. */
163+ /* */
164+ /* Note that if your compiler or CPU is not supported, this will default */
165+ /* to the standard and portable implementation found in `ftcalc.c'. */
166+ /* */
167+#define FT_CONFIG_OPTION_INLINE_MULFIX
168+
169+
170+ /*************************************************************************/
171+ /* */
172+ /* LZW-compressed file support. */
173+ /* */
174+ /* FreeType now handles font files that have been compressed with the */
175+ /* `compress' program. This is mostly used to parse many of the PCF */
176+ /* files that come with various X11 distributions. The implementation */
177+ /* uses NetBSD's `zopen' to partially uncompress the file on the fly */
178+ /* (see src/lzw/ftgzip.c). */
179+ /* */
180+ /* Define this macro if you want to enable this `feature'. */
181+ /* */
182+#define FT_CONFIG_OPTION_USE_LZW
183+
184+
185+ /*************************************************************************/
186+ /* */
187+ /* Gzip-compressed file support. */
188+ /* */
189+ /* FreeType now handles font files that have been compressed with the */
190+ /* `gzip' program. This is mostly used to parse many of the PCF files */
191+ /* that come with XFree86. The implementation uses `zlib' to */
192+ /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */
193+ /* */
194+ /* Define this macro if you want to enable this `feature'. See also */
195+ /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */
196+ /* */
197+#define FT_CONFIG_OPTION_USE_ZLIB
198+
199+
200+ /*************************************************************************/
201+ /* */
202+ /* ZLib library selection */
203+ /* */
204+ /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */
205+ /* It allows FreeType's `ftgzip' component to link to the system's */
206+ /* installation of the ZLib library. This is useful on systems like */
207+ /* Unix or VMS where it generally is already available. */
208+ /* */
209+ /* If you let it undefined, the component will use its own copy */
210+ /* of the zlib sources instead. These have been modified to be */
211+ /* included directly within the component and *not* export external */
212+ /* function names. This allows you to link any program with FreeType */
213+ /* _and_ ZLib without linking conflicts. */
214+ /* */
215+ /* Do not #undef this macro here since the build system might define */
216+ /* it for certain configurations only. */
217+ /* */
218+ /* If you use a build system like cmake or the `configure' script, */
219+ /* options set by those programs have precendence, overwriting the */
220+ /* value here with the configured one. */
221+ /* */
222+#define FT_CONFIG_OPTION_SYSTEM_ZLIB
223+
224+
225+ /*************************************************************************/
226+ /* */
227+ /* Bzip2-compressed file support. */
228+ /* */
229+ /* FreeType now handles font files that have been compressed with the */
230+ /* `bzip2' program. This is mostly used to parse many of the PCF */
231+ /* files that come with XFree86. The implementation uses `libbz2' to */
232+ /* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */
233+ /* Contrary to gzip, bzip2 currently is not included and need to use */
234+ /* the system available bzip2 implementation. */
235+ /* */
236+ /* Define this macro if you want to enable this `feature'. */
237+ /* */
238+ /* If you use a build system like cmake or the `configure' script, */
239+ /* options set by those programs have precendence, overwriting the */
240+ /* value here with the configured one. */
241+ /* */
242+#define FT_CONFIG_OPTION_USE_BZIP2
243+
244+
245+ /*************************************************************************/
246+ /* */
247+ /* Define to disable the use of file stream functions and types, FILE, */
248+ /* fopen() etc. Enables the use of smaller system libraries on embedded */
249+ /* systems that have multiple system libraries, some with or without */
250+ /* file stream support, in the cases where file stream support is not */
251+ /* necessary such as memory loading of font files. */
252+ /* */
253+/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
254+
255+
256+ /*************************************************************************/
257+ /* */
258+ /* PNG bitmap support. */
259+ /* */
260+ /* FreeType now handles loading color bitmap glyphs in the PNG format. */
261+ /* This requires help from the external libpng library. Uncompressed */
262+ /* color bitmaps do not need any external libraries and will be */
263+ /* supported regardless of this configuration. */
264+ /* */
265+ /* Define this macro if you want to enable this `feature'. */
266+ /* */
267+ /* If you use a build system like cmake or the `configure' script, */
268+ /* options set by those programs have precendence, overwriting the */
269+ /* value here with the configured one. */
270+ /* */
271+#define FT_CONFIG_OPTION_USE_PNG
272+
273+
274+ /*************************************************************************/
275+ /* */
276+ /* HarfBuzz support. */
277+ /* */
278+ /* FreeType uses the HarfBuzz library to improve auto-hinting of */
279+ /* OpenType fonts. If available, many glyphs not directly addressable */
280+ /* by a font's character map will be hinted also. */
281+ /* */
282+ /* Define this macro if you want to enable this `feature'. */
283+ /* */
284+ /* If you use a build system like cmake or the `configure' script, */
285+ /* options set by those programs have precendence, overwriting the */
286+ /* value here with the configured one. */
287+ /* */
288+/* #undef FT_CONFIG_OPTION_USE_HARFBUZZ */
289+
290+
291+ /*************************************************************************/
292+ /* */
293+ /* Glyph Postscript Names handling */
294+ /* */
295+ /* By default, FreeType 2 is compiled with the `psnames' module. This */
296+ /* module is in charge of converting a glyph name string into a */
297+ /* Unicode value, or return a Macintosh standard glyph name for the */
298+ /* use with the TrueType `post' table. */
299+ /* */
300+ /* Undefine this macro if you do not want `psnames' compiled in your */
301+ /* build of FreeType. This has the following effects: */
302+ /* */
303+ /* - The TrueType driver will provide its own set of glyph names, */
304+ /* if you build it to support postscript names in the TrueType */
305+ /* `post' table, but will not synthesize a missing Unicode charmap. */
306+ /* */
307+ /* - The Type 1 driver will not be able to synthesize a Unicode */
308+ /* charmap out of the glyphs found in the fonts. */
309+ /* */
310+ /* You would normally undefine this configuration macro when building */
311+ /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */
312+ /* */
313+#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES
314+
315+
316+ /*************************************************************************/
317+ /* */
318+ /* Postscript Names to Unicode Values support */
319+ /* */
320+ /* By default, FreeType 2 is built with the `PSNames' module compiled */
321+ /* in. Among other things, the module is used to convert a glyph name */
322+ /* into a Unicode value. This is especially useful in order to */
323+ /* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */
324+ /* through a big table named the `Adobe Glyph List' (AGL). */
325+ /* */
326+ /* Undefine this macro if you do not want the Adobe Glyph List */
327+ /* compiled in your `PSNames' module. The Type 1 driver will not be */
328+ /* able to synthesize a Unicode charmap out of the glyphs found in the */
329+ /* fonts. */
330+ /* */
331+#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
332+
333+
334+ /*************************************************************************/
335+ /* */
336+ /* Support for Mac fonts */
337+ /* */
338+ /* Define this macro if you want support for outline fonts in Mac */
339+ /* format (mac dfont, mac resource, macbinary containing a mac */
340+ /* resource) on non-Mac platforms. */
341+ /* */
342+ /* Note that the `FOND' resource isn't checked. */
343+ /* */
344+#define FT_CONFIG_OPTION_MAC_FONTS
345+
346+
347+ /*************************************************************************/
348+ /* */
349+ /* Guessing methods to access embedded resource forks */
350+ /* */
351+ /* Enable extra Mac fonts support on non-Mac platforms (e.g. */
352+ /* GNU/Linux). */
353+ /* */
354+ /* Resource forks which include fonts data are stored sometimes in */
355+ /* locations which users or developers don't expected. In some cases, */
356+ /* resource forks start with some offset from the head of a file. In */
357+ /* other cases, the actual resource fork is stored in file different */
358+ /* from what the user specifies. If this option is activated, */
359+ /* FreeType tries to guess whether such offsets or different file */
360+ /* names must be used. */
361+ /* */
362+ /* Note that normal, direct access of resource forks is controlled via */
363+ /* the FT_CONFIG_OPTION_MAC_FONTS option. */
364+ /* */
365+#ifdef FT_CONFIG_OPTION_MAC_FONTS
366+#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
367+#endif
368+
369+
370+ /*************************************************************************/
371+ /* */
372+ /* Allow the use of FT_Incremental_Interface to load typefaces that */
373+ /* contain no glyph data, but supply it via a callback function. */
374+ /* This is required by clients supporting document formats which */
375+ /* supply font data incrementally as the document is parsed, such */
376+ /* as the Ghostscript interpreter for the PostScript language. */
377+ /* */
378+#define FT_CONFIG_OPTION_INCREMENTAL
379+
380+
381+ /*************************************************************************/
382+ /* */
383+ /* The size in bytes of the render pool used by the scan-line converter */
384+ /* to do all of its work. */
385+ /* */
386+#define FT_RENDER_POOL_SIZE 16384L
387+
388+
389+ /*************************************************************************/
390+ /* */
391+ /* FT_MAX_MODULES */
392+ /* */
393+ /* The maximum number of modules that can be registered in a single */
394+ /* FreeType library object. 32 is the default. */
395+ /* */
396+#define FT_MAX_MODULES 32
397+
398+
399+ /*************************************************************************/
400+ /* */
401+ /* Debug level */
402+ /* */
403+ /* FreeType can be compiled in debug or trace mode. In debug mode, */
404+ /* errors are reported through the `ftdebug' component. In trace */
405+ /* mode, additional messages are sent to the standard output during */
406+ /* execution. */
407+ /* */
408+ /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */
409+ /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */
410+ /* */
411+ /* Don't define any of these macros to compile in `release' mode! */
412+ /* */
413+ /* Do not #undef these macros here since the build system might define */
414+ /* them for certain configurations only. */
415+ /* */
416+/* #define FT_DEBUG_LEVEL_ERROR */
417+/* #define FT_DEBUG_LEVEL_TRACE */
418+
419+
420+ /*************************************************************************/
421+ /* */
422+ /* Autofitter debugging */
423+ /* */
424+ /* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */
425+ /* control the autofitter behaviour for debugging purposes with global */
426+ /* boolean variables (consequently, you should *never* enable this */
427+ /* while compiling in `release' mode): */
428+ /* */
429+ /* _af_debug_disable_horz_hints */
430+ /* _af_debug_disable_vert_hints */
431+ /* _af_debug_disable_blue_hints */
432+ /* */
433+ /* Additionally, the following functions provide dumps of various */
434+ /* internal autofit structures to stdout (using `printf'): */
435+ /* */
436+ /* af_glyph_hints_dump_points */
437+ /* af_glyph_hints_dump_segments */
438+ /* af_glyph_hints_dump_edges */
439+ /* af_glyph_hints_get_num_segments */
440+ /* af_glyph_hints_get_segment_offset */
441+ /* */
442+ /* As an argument, they use another global variable: */
443+ /* */
444+ /* _af_debug_hints */
445+ /* */
446+ /* Please have a look at the `ftgrid' demo program to see how those */
447+ /* variables and macros should be used. */
448+ /* */
449+ /* Do not #undef these macros here since the build system might define */
450+ /* them for certain configurations only. */
451+ /* */
452+/* #define FT_DEBUG_AUTOFIT */
453+
454+
455+ /*************************************************************************/
456+ /* */
457+ /* Memory Debugging */
458+ /* */
459+ /* FreeType now comes with an integrated memory debugger that is */
460+ /* capable of detecting simple errors like memory leaks or double */
461+ /* deletes. To compile it within your build of the library, you */
462+ /* should define FT_DEBUG_MEMORY here. */
463+ /* */
464+ /* Note that the memory debugger is only activated at runtime when */
465+ /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */
466+ /* */
467+ /* Do not #undef this macro here since the build system might define */
468+ /* it for certain configurations only. */
469+ /* */
470+/* #define FT_DEBUG_MEMORY */
471+
472+
473+ /*************************************************************************/
474+ /* */
475+ /* Module errors */
476+ /* */
477+ /* If this macro is set (which is _not_ the default), the higher byte */
478+ /* of an error code gives the module in which the error has occurred, */
479+ /* while the lower byte is the real error code. */
480+ /* */
481+ /* Setting this macro makes sense for debugging purposes only, since */
482+ /* it would break source compatibility of certain programs that use */
483+ /* FreeType 2. */
484+ /* */
485+ /* More details can be found in the files ftmoderr.h and fterrors.h. */
486+ /* */
487+#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
488+
489+
490+ /*************************************************************************/
491+ /* */
492+ /* Position Independent Code */
493+ /* */
494+ /* If this macro is set (which is _not_ the default), FreeType2 will */
495+ /* avoid creating constants that require address fixups. Instead the */
496+ /* constants will be moved into a struct and additional intialization */
497+ /* code will be used. */
498+ /* */
499+ /* Setting this macro is needed for systems that prohibit address */
500+ /* fixups, such as BREW. [Note that standard compilers like gcc or */
501+ /* clang handle PIC generation automatically; you don't have to set */
502+ /* FT_CONFIG_OPTION_PIC, which is only necessary for very special */
503+ /* compilers.] */
504+ /* */
505+ /* Note that FT_CONFIG_OPTION_PIC support is not available for all */
506+ /* modules (see `modules.cfg' for a complete list). For building with */
507+ /* FT_CONFIG_OPTION_PIC support, do the following. */
508+ /* */
509+ /* 0. Clone the repository. */
510+ /* 1. Define FT_CONFIG_OPTION_PIC. */
511+ /* 2. Remove all subdirectories in `src' that don't have */
512+ /* FT_CONFIG_OPTION_PIC support. */
513+ /* 3. Comment out the corresponding modules in `modules.cfg'. */
514+ /* 4. Compile. */
515+ /* */
516+/* #define FT_CONFIG_OPTION_PIC */
517+
518+
519+ /*************************************************************************/
520+ /*************************************************************************/
521+ /**** ****/
522+ /**** S F N T D R I V E R C O N F I G U R A T I O N ****/
523+ /**** ****/
524+ /*************************************************************************/
525+ /*************************************************************************/
526+
527+
528+ /*************************************************************************/
529+ /* */
530+ /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */
531+ /* embedded bitmaps in all formats using the SFNT module (namely */
532+ /* TrueType & OpenType). */
533+ /* */
534+#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS
535+
536+
537+ /*************************************************************************/
538+ /* */
539+ /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */
540+ /* load and enumerate the glyph Postscript names in a TrueType or */
541+ /* OpenType file. */
542+ /* */
543+ /* Note that when you do not compile the `PSNames' module by undefining */
544+ /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */
545+ /* contain additional code used to read the PS Names table from a font. */
546+ /* */
547+ /* (By default, the module uses `PSNames' to extract glyph names.) */
548+ /* */
549+#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES
550+
551+
552+ /*************************************************************************/
553+ /* */
554+ /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */
555+ /* access the internal name table in a SFNT-based format like TrueType */
556+ /* or OpenType. The name table contains various strings used to */
557+ /* describe the font, like family name, copyright, version, etc. It */
558+ /* does not contain any glyph name though. */
559+ /* */
560+ /* Accessing SFNT names is done through the functions declared in */
561+ /* `ftsnames.h'. */
562+ /* */
563+#define TT_CONFIG_OPTION_SFNT_NAMES
564+
565+
566+ /*************************************************************************/
567+ /* */
568+ /* TrueType CMap support */
569+ /* */
570+ /* Here you can fine-tune which TrueType CMap table format shall be */
571+ /* supported. */
572+#define TT_CONFIG_CMAP_FORMAT_0
573+#define TT_CONFIG_CMAP_FORMAT_2
574+#define TT_CONFIG_CMAP_FORMAT_4
575+#define TT_CONFIG_CMAP_FORMAT_6
576+#define TT_CONFIG_CMAP_FORMAT_8
577+#define TT_CONFIG_CMAP_FORMAT_10
578+#define TT_CONFIG_CMAP_FORMAT_12
579+#define TT_CONFIG_CMAP_FORMAT_13
580+#define TT_CONFIG_CMAP_FORMAT_14
581+
582+
583+ /*************************************************************************/
584+ /*************************************************************************/
585+ /**** ****/
586+ /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/
587+ /**** ****/
588+ /*************************************************************************/
589+ /*************************************************************************/
590+
591+ /*************************************************************************/
592+ /* */
593+ /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */
594+ /* a bytecode interpreter in the TrueType driver. */
595+ /* */
596+ /* By undefining this, you will only compile the code necessary to load */
597+ /* TrueType glyphs without hinting. */
598+ /* */
599+ /* Do not #undef this macro here, since the build system might */
600+ /* define it for certain configurations only. */
601+ /* */
602+#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
603+
604+
605+ /*************************************************************************/
606+ /* */
607+ /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */
608+ /* subpixel hinting support into the TrueType driver. This modifies the */
609+ /* TrueType hinting mechanism when anything but FT_RENDER_MODE_MONO is */
610+ /* requested. */
611+ /* */
612+ /* In particular, it modifies the bytecode interpreter to interpret (or */
613+ /* not) instructions in a certain way so that all TrueType fonts look */
614+ /* like they do in a Windows ClearType (DirectWrite) environment. See */
615+ /* [1] for a technical overview on what this means. See `ttinterp.h' */
616+ /* for more details on the LEAN option. */
617+ /* */
618+ /* There are three possible values. */
619+ /* */
620+ /* Value 1: */
621+ /* This value is associated with the `Infinality' moniker, */
622+ /* contributed by an individual nicknamed Infinality with the goal of */
623+ /* making TrueType fonts render better than on Windows. A high */
624+ /* amount of configurability and flexibility, down to rules for */
625+ /* single glyphs in fonts, but also very slow. Its experimental and */
626+ /* slow nature and the original developer losing interest meant that */
627+ /* this option was never enabled in default builds. */
628+ /* */
629+ /* The corresponding interpreter version is v38. */
630+ /* */
631+ /* Value 2: */
632+ /* The new default mode for the TrueType driver. The Infinality code */
633+ /* base was stripped to the bare minimum and all configurability */
634+ /* removed in the name of speed and simplicity. The configurability */
635+ /* was mainly aimed at legacy fonts like Arial, Times New Roman, or */
636+ /* Courier. Legacy fonts are fonts that modify vertical stems to */
637+ /* achieve clean black-and-white bitmaps. The new mode focuses on */
638+ /* applying a minimal set of rules to all fonts indiscriminately so */
639+ /* that modern and web fonts render well while legacy fonts render */
640+ /* okay. */
641+ /* */
642+ /* The corresponding interpreter version is v40. */
643+ /* */
644+ /* Value 3: */
645+ /* Compile both, making both v38 and v40 available (the latter is the */
646+ /* default). */
647+ /* */
648+ /* By undefining these, you get rendering behavior like on Windows */
649+ /* without ClearType, i.e., Windows XP without ClearType enabled and */
650+ /* Win9x (interpreter version v35). Or not, depending on how much */
651+ /* hinting blood and testing tears the font designer put into a given */
652+ /* font. If you define one or both subpixel hinting options, you can */
653+ /* switch between between v35 and the ones you define (using */
654+ /* `FT_Property_Set'). */
655+ /* */
656+ /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */
657+ /* defined. */
658+ /* */
659+ /* [1] https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
660+ /* */
661+/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */
662+#define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2
663+/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */
664+
665+
666+ /*************************************************************************/
667+ /* */
668+ /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */
669+ /* TrueType glyph loader to use Apple's definition of how to handle */
670+ /* component offsets in composite glyphs. */
671+ /* */
672+ /* Apple and MS disagree on the default behavior of component offsets */
673+ /* in composites. Apple says that they should be scaled by the scaling */
674+ /* factors in the transformation matrix (roughly, it's more complex) */
675+ /* while MS says they should not. OpenType defines two bits in the */
676+ /* composite flags array which can be used to disambiguate, but old */
677+ /* fonts will not have them. */
678+ /* */
679+ /* https://www.microsoft.com/typography/otspec/glyf.htm */
680+ /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html */
681+ /* */
682+#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
683+
684+
685+ /*************************************************************************/
686+ /* */
687+ /* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */
688+ /* support for Apple's distortable font technology (fvar, gvar, cvar, */
689+ /* and avar tables). This has many similarities to Type 1 Multiple */
690+ /* Masters support. */
691+ /* */
692+#define TT_CONFIG_OPTION_GX_VAR_SUPPORT
693+
694+
695+ /*************************************************************************/
696+ /* */
697+ /* Define TT_CONFIG_OPTION_BDF if you want to include support for */
698+ /* an embedded `BDF ' table within SFNT-based bitmap formats. */
699+ /* */
700+#define TT_CONFIG_OPTION_BDF
701+
702+
703+ /*************************************************************************/
704+ /* */
705+ /* Option TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES controls the maximum */
706+ /* number of bytecode instructions executed for a single run of the */
707+ /* bytecode interpreter, needed to prevent infinite loops. You don't */
708+ /* want to change this except for very special situations (e.g., making */
709+ /* a library fuzzer spend less time to handle broken fonts). */
710+ /* */
711+ /* It is not expected that this value is ever modified by a configuring */
712+ /* script; instead, it gets surrounded with #ifndef ... #endif so that */
713+ /* the value can be set as a preprocessor option on the compiler's */
714+ /* command line. */
715+ /* */
716+#ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES
717+#define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L
718+#endif
719+
720+
721+ /*************************************************************************/
722+ /*************************************************************************/
723+ /**** ****/
724+ /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/
725+ /**** ****/
726+ /*************************************************************************/
727+ /*************************************************************************/
728+
729+
730+ /*************************************************************************/
731+ /* */
732+ /* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */
733+ /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */
734+ /* required. */
735+ /* */
736+#define T1_MAX_DICT_DEPTH 5
737+
738+
739+ /*************************************************************************/
740+ /* */
741+ /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
742+ /* calls during glyph loading. */
743+ /* */
744+#define T1_MAX_SUBRS_CALLS 16
745+
746+
747+ /*************************************************************************/
748+ /* */
749+ /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
750+ /* minimum of 16 is required. */
751+ /* */
752+ /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */
753+ /* */
754+#define T1_MAX_CHARSTRINGS_OPERANDS 256
755+
756+
757+ /*************************************************************************/
758+ /* */
759+ /* Define this configuration macro if you want to prevent the */
760+ /* compilation of `t1afm', which is in charge of reading Type 1 AFM */
761+ /* files into an existing face. Note that if set, the T1 driver will be */
762+ /* unable to produce kerning distances. */
763+ /* */
764+#undef T1_CONFIG_OPTION_NO_AFM
765+
766+
767+ /*************************************************************************/
768+ /* */
769+ /* Define this configuration macro if you want to prevent the */
770+ /* compilation of the Multiple Masters font support in the Type 1 */
771+ /* driver. */
772+ /* */
773+#undef T1_CONFIG_OPTION_NO_MM_SUPPORT
774+
775+
776+ /*************************************************************************/
777+ /* */
778+ /* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */
779+ /* engine gets compiled into FreeType. If defined, it is possible to */
780+ /* switch between the two engines using the `hinting-engine' property of */
781+ /* the type1 driver module. */
782+ /* */
783+/* #define T1_CONFIG_OPTION_OLD_ENGINE */
784+
785+
786+ /*************************************************************************/
787+ /*************************************************************************/
788+ /**** ****/
789+ /**** C F F D R I V E R C O N F I G U R A T I O N ****/
790+ /**** ****/
791+ /*************************************************************************/
792+ /*************************************************************************/
793+
794+
795+ /*************************************************************************/
796+ /* */
797+ /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is */
798+ /* possible to set up the default values of the four control points that */
799+ /* define the stem darkening behaviour of the (new) CFF engine. For */
800+ /* more details please read the documentation of the */
801+ /* `darkening-parameters' property (file `ftdriver.h'), which allows the */
802+ /* control at run-time. */
803+ /* */
804+ /* Do *not* undefine these macros! */
805+ /* */
806+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500
807+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400
808+
809+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000
810+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275
811+
812+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667
813+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275
814+
815+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333
816+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0
817+
818+
819+ /*************************************************************************/
820+ /* */
821+ /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */
822+ /* engine gets compiled into FreeType. If defined, it is possible to */
823+ /* switch between the two engines using the `hinting-engine' property of */
824+ /* the cff driver module. */
825+ /* */
826+/* #define CFF_CONFIG_OPTION_OLD_ENGINE */
827+
828+
829+ /*************************************************************************/
830+ /*************************************************************************/
831+ /**** ****/
832+ /**** P C F D R I V E R C O N F I G U R A T I O N ****/
833+ /**** ****/
834+ /*************************************************************************/
835+ /*************************************************************************/
836+
837+
838+ /*************************************************************************/
839+ /* */
840+ /* There are many PCF fonts just called `Fixed' which look completely */
841+ /* different, and which have nothing to do with each other. When */
842+ /* selecting `Fixed' in KDE or Gnome one gets results that appear rather */
843+ /* random, the style changes often if one changes the size and one */
844+ /* cannot select some fonts at all. This option makes the PCF module */
845+ /* prepend the foundry name (plus a space) to the family name. */
846+ /* */
847+ /* We also check whether we have `wide' characters; all put together, we */
848+ /* get family names like `Sony Fixed' or `Misc Fixed Wide'. */
849+ /* */
850+ /* If this option is activated, it can be controlled with the */
851+ /* `no-long-family-names' property of the pcf driver module. */
852+ /* */
853+/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
854+
855+
856+ /*************************************************************************/
857+ /*************************************************************************/
858+ /**** ****/
859+ /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/
860+ /**** ****/
861+ /*************************************************************************/
862+ /*************************************************************************/
863+
864+
865+ /*************************************************************************/
866+ /* */
867+ /* Compile autofit module with CJK (Chinese, Japanese, Korean) script */
868+ /* support. */
869+ /* */
870+#define AF_CONFIG_OPTION_CJK
871+
872+ /*************************************************************************/
873+ /* */
874+ /* Compile autofit module with fallback Indic script support, covering */
875+ /* some scripts that the `latin' submodule of the autofit module doesn't */
876+ /* (yet) handle. */
877+ /* */
878+#define AF_CONFIG_OPTION_INDIC
879+
880+ /*************************************************************************/
881+ /* */
882+ /* Compile autofit module with warp hinting. The idea of the warping */
883+ /* code is to slightly scale and shift a glyph within a single dimension */
884+ /* so that as much of its segments are aligned (more or less) on the */
885+ /* grid. To find out the optimal scaling and shifting value, various */
886+ /* parameter combinations are tried and scored. */
887+ /* */
888+ /* This experimental option is active only if the rendering mode is */
889+ /* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */
890+ /* `warping' property of the auto-hinter (see file `ftdriver.h' for more */
891+ /* information; by default it is switched off). */
892+ /* */
893+#define AF_CONFIG_OPTION_USE_WARPER
894+
895+ /*************************************************************************/
896+ /* */
897+ /* Use TrueType-like size metrics for `light' auto-hinting. */
898+ /* */
899+ /* It is strongly recommended to avoid this option, which exists only to */
900+ /* help some legacy applications retain its appearance and behaviour */
901+ /* with respect to auto-hinted TrueType fonts. */
902+ /* */
903+ /* The very reason this option exists at all are GNU/Linux distributions */
904+ /* like Fedora that did not un-patch the following change (which was */
905+ /* present in FreeType between versions 2.4.6 and 2.7.1, inclusive). */
906+ /* */
907+ /* 2011-07-16 Steven Chu <steven.f.chu@gmail.com> */
908+ /* */
909+ /* [truetype] Fix metrics on size request for scalable fonts. */
910+ /* */
911+ /* This problematic commit is now reverted (more or less). */
912+ /* */
913+/* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */
914+
915+ /* */
916+
917+
918+ /*
919+ * This macro is obsolete. Support has been removed in FreeType
920+ * version 2.5.
921+ */
922+/* #define FT_CONFIG_OPTION_OLD_INTERNALS */
923+
924+
925+ /*
926+ * This macro is defined if native TrueType hinting is requested by the
927+ * definitions above.
928+ */
929+#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
930+#define TT_USE_BYTECODE_INTERPRETER
931+
932+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
933+#if TT_CONFIG_OPTION_SUBPIXEL_HINTING & 1
934+#define TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
935+#endif
936+
937+#if TT_CONFIG_OPTION_SUBPIXEL_HINTING & 2
938+#define TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
939+#endif
940+#endif
941+#endif
942+
943+
944+ /*
945+ * Check CFF darkening parameters. The checks are the same as in function
946+ * `cff_property_set' in file `cffdrivr.c'.
947+ */
948+#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \
949+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \
950+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \
951+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \
952+ \
953+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \
954+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \
955+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \
956+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \
957+ \
958+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \
959+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \
960+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \
961+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \
962+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \
963+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \
964+ \
965+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \
966+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \
967+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \
968+ CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500
969+#error "Invalid CFF darkening parameters!"
970+#endif
971+
972+FT_END_HEADER
973+
974+
975+#endif /* FTOPTION_H_ */
976+
977+
978+/* END */
1@@ -0,0 +1,175 @@
2+/***************************************************************************/
3+/* */
4+/* ftstdlib.h */
5+/* */
6+/* ANSI-specific library and header configuration file (specification */
7+/* only). */
8+/* */
9+/* Copyright 2002-2018 by */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+
21+ /*************************************************************************/
22+ /* */
23+ /* This file is used to group all #includes to the ANSI C library that */
24+ /* FreeType normally requires. It also defines macros to rename the */
25+ /* standard functions within the FreeType source code. */
26+ /* */
27+ /* Load a file which defines FTSTDLIB_H_ before this one to override it. */
28+ /* */
29+ /*************************************************************************/
30+
31+
32+#ifndef FTSTDLIB_H_
33+#define FTSTDLIB_H_
34+
35+
36+#include <stddef.h>
37+
38+#define ft_ptrdiff_t ptrdiff_t
39+
40+
41+ /**********************************************************************/
42+ /* */
43+ /* integer limits */
44+ /* */
45+ /* UINT_MAX and ULONG_MAX are used to automatically compute the size */
46+ /* of `int' and `long' in bytes at compile-time. So far, this works */
47+ /* for all platforms the library has been tested on. */
48+ /* */
49+ /* Note that on the extremely rare platforms that do not provide */
50+ /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */
51+ /* old Crays where `int' is 36 bits), we do not make any guarantee */
52+ /* about the correct behaviour of FT2 with all fonts. */
53+ /* */
54+ /* In these case, `ftconfig.h' will refuse to compile anyway with a */
55+ /* message like `couldn't find 32-bit type' or something similar. */
56+ /* */
57+ /**********************************************************************/
58+
59+
60+#include <limits.h>
61+
62+#define FT_CHAR_BIT CHAR_BIT
63+#define FT_USHORT_MAX USHRT_MAX
64+#define FT_INT_MAX INT_MAX
65+#define FT_INT_MIN INT_MIN
66+#define FT_UINT_MAX UINT_MAX
67+#define FT_LONG_MIN LONG_MIN
68+#define FT_LONG_MAX LONG_MAX
69+#define FT_ULONG_MAX ULONG_MAX
70+
71+
72+ /**********************************************************************/
73+ /* */
74+ /* character and string processing */
75+ /* */
76+ /**********************************************************************/
77+
78+
79+#include <string.h>
80+
81+#define ft_memchr memchr
82+#define ft_memcmp memcmp
83+#define ft_memcpy memcpy
84+#define ft_memmove memmove
85+#define ft_memset memset
86+#define ft_strcat strcat
87+#define ft_strcmp strcmp
88+#define ft_strcpy strcpy
89+#define ft_strlen strlen
90+#define ft_strncmp strncmp
91+#define ft_strncpy strncpy
92+#define ft_strrchr strrchr
93+#define ft_strstr strstr
94+
95+
96+ /**********************************************************************/
97+ /* */
98+ /* file handling */
99+ /* */
100+ /**********************************************************************/
101+
102+
103+#include <stdio.h>
104+
105+#define FT_FILE FILE
106+#define ft_fclose fclose
107+#define ft_fopen fopen
108+#define ft_fread fread
109+#define ft_fseek fseek
110+#define ft_ftell ftell
111+#define ft_sprintf sprintf
112+
113+
114+ /**********************************************************************/
115+ /* */
116+ /* sorting */
117+ /* */
118+ /**********************************************************************/
119+
120+
121+#include <stdlib.h>
122+
123+#define ft_qsort qsort
124+
125+
126+ /**********************************************************************/
127+ /* */
128+ /* memory allocation */
129+ /* */
130+ /**********************************************************************/
131+
132+
133+#define ft_scalloc calloc
134+#define ft_sfree free
135+#define ft_smalloc malloc
136+#define ft_srealloc realloc
137+
138+
139+ /**********************************************************************/
140+ /* */
141+ /* miscellaneous */
142+ /* */
143+ /**********************************************************************/
144+
145+
146+#define ft_strtol strtol
147+#define ft_getenv getenv
148+
149+
150+ /**********************************************************************/
151+ /* */
152+ /* execution control */
153+ /* */
154+ /**********************************************************************/
155+
156+
157+#include <setjmp.h>
158+
159+#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */
160+ /* jmp_buf is defined as a macro */
161+ /* on certain platforms */
162+
163+#define ft_longjmp longjmp
164+#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */
165+
166+
167+ /* the following is only used for debugging purposes, i.e., if */
168+ /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */
169+
170+#include <stdarg.h>
171+
172+
173+#endif /* FTSTDLIB_H_ */
174+
175+
176+/* END */
+4657,
-0
1@@ -0,0 +1,4657 @@
2+/***************************************************************************/
3+/* */
4+/* freetype.h */
5+/* */
6+/* FreeType high-level API and common types (specification only). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FREETYPE_H_
21+#define FREETYPE_H_
22+
23+
24+#ifndef FT_FREETYPE_H
25+#error "`ft2build.h' hasn't been included yet!"
26+#error "Please always use macros to include FreeType header files."
27+#error "Example:"
28+#error " #include <ft2build.h>"
29+#error " #include FT_FREETYPE_H"
30+#endif
31+
32+
33+#include <ft2build.h>
34+#include FT_CONFIG_CONFIG_H
35+#include FT_TYPES_H
36+#include FT_ERRORS_H
37+
38+
39+FT_BEGIN_HEADER
40+
41+
42+
43+ /*************************************************************************/
44+ /* */
45+ /* <Section> */
46+ /* header_inclusion */
47+ /* */
48+ /* <Title> */
49+ /* FreeType's header inclusion scheme */
50+ /* */
51+ /* <Abstract> */
52+ /* How client applications should include FreeType header files. */
53+ /* */
54+ /* <Description> */
55+ /* To be as flexible as possible (and for historical reasons), */
56+ /* FreeType uses a very special inclusion scheme to load header */
57+ /* files, for example */
58+ /* */
59+ /* { */
60+ /* #include <ft2build.h> */
61+ /* */
62+ /* #include FT_FREETYPE_H */
63+ /* #include FT_OUTLINE_H */
64+ /* } */
65+ /* */
66+ /* A compiler and its preprocessor only needs an include path to find */
67+ /* the file `ft2build.h'; the exact locations and names of the other */
68+ /* FreeType header files are hidden by preprocessor macro names, */
69+ /* loaded by `ft2build.h'. The API documentation always gives the */
70+ /* header macro name needed for a particular function. */
71+ /* */
72+ /*************************************************************************/
73+
74+
75+ /*************************************************************************/
76+ /* */
77+ /* <Section> */
78+ /* user_allocation */
79+ /* */
80+ /* <Title> */
81+ /* User allocation */
82+ /* */
83+ /* <Abstract> */
84+ /* How client applications should allocate FreeType data structures. */
85+ /* */
86+ /* <Description> */
87+ /* FreeType assumes that structures allocated by the user and passed */
88+ /* as arguments are zeroed out except for the actual data. In other */
89+ /* words, it is recommended to use `calloc' (or variants of it) */
90+ /* instead of `malloc' for allocation. */
91+ /* */
92+ /*************************************************************************/
93+
94+
95+
96+ /*************************************************************************/
97+ /*************************************************************************/
98+ /* */
99+ /* B A S I C T Y P E S */
100+ /* */
101+ /*************************************************************************/
102+ /*************************************************************************/
103+
104+
105+ /*************************************************************************/
106+ /* */
107+ /* <Section> */
108+ /* base_interface */
109+ /* */
110+ /* <Title> */
111+ /* Base Interface */
112+ /* */
113+ /* <Abstract> */
114+ /* The FreeType~2 base font interface. */
115+ /* */
116+ /* <Description> */
117+ /* This section describes the most important public high-level API */
118+ /* functions of FreeType~2. */
119+ /* */
120+ /* <Order> */
121+ /* FT_Library */
122+ /* FT_Face */
123+ /* FT_Size */
124+ /* FT_GlyphSlot */
125+ /* FT_CharMap */
126+ /* FT_Encoding */
127+ /* FT_ENC_TAG */
128+ /* */
129+ /* FT_FaceRec */
130+ /* */
131+ /* FT_FACE_FLAG_SCALABLE */
132+ /* FT_FACE_FLAG_FIXED_SIZES */
133+ /* FT_FACE_FLAG_FIXED_WIDTH */
134+ /* FT_FACE_FLAG_HORIZONTAL */
135+ /* FT_FACE_FLAG_VERTICAL */
136+ /* FT_FACE_FLAG_COLOR */
137+ /* FT_FACE_FLAG_SFNT */
138+ /* FT_FACE_FLAG_CID_KEYED */
139+ /* FT_FACE_FLAG_TRICKY */
140+ /* FT_FACE_FLAG_KERNING */
141+ /* FT_FACE_FLAG_MULTIPLE_MASTERS */
142+ /* FT_FACE_FLAG_VARIATION */
143+ /* FT_FACE_FLAG_GLYPH_NAMES */
144+ /* FT_FACE_FLAG_EXTERNAL_STREAM */
145+ /* FT_FACE_FLAG_HINTER */
146+ /* */
147+ /* FT_HAS_HORIZONTAL */
148+ /* FT_HAS_VERTICAL */
149+ /* FT_HAS_KERNING */
150+ /* FT_HAS_FIXED_SIZES */
151+ /* FT_HAS_GLYPH_NAMES */
152+ /* FT_HAS_COLOR */
153+ /* FT_HAS_MULTIPLE_MASTERS */
154+ /* */
155+ /* FT_IS_SFNT */
156+ /* FT_IS_SCALABLE */
157+ /* FT_IS_FIXED_WIDTH */
158+ /* FT_IS_CID_KEYED */
159+ /* FT_IS_TRICKY */
160+ /* FT_IS_NAMED_INSTANCE */
161+ /* FT_IS_VARIATION */
162+ /* */
163+ /* FT_STYLE_FLAG_BOLD */
164+ /* FT_STYLE_FLAG_ITALIC */
165+ /* */
166+ /* FT_SizeRec */
167+ /* FT_Size_Metrics */
168+ /* */
169+ /* FT_GlyphSlotRec */
170+ /* FT_Glyph_Metrics */
171+ /* FT_SubGlyph */
172+ /* */
173+ /* FT_Bitmap_Size */
174+ /* */
175+ /* FT_Init_FreeType */
176+ /* FT_Done_FreeType */
177+ /* */
178+ /* FT_New_Face */
179+ /* FT_Done_Face */
180+ /* FT_Reference_Face */
181+ /* FT_New_Memory_Face */
182+ /* FT_Face_Properties */
183+ /* FT_Open_Face */
184+ /* FT_Open_Args */
185+ /* FT_Parameter */
186+ /* FT_Attach_File */
187+ /* FT_Attach_Stream */
188+ /* */
189+ /* FT_Set_Char_Size */
190+ /* FT_Set_Pixel_Sizes */
191+ /* FT_Request_Size */
192+ /* FT_Select_Size */
193+ /* FT_Size_Request_Type */
194+ /* FT_Size_RequestRec */
195+ /* FT_Size_Request */
196+ /* FT_Set_Transform */
197+ /* FT_Load_Glyph */
198+ /* FT_Get_Char_Index */
199+ /* FT_Get_First_Char */
200+ /* FT_Get_Next_Char */
201+ /* FT_Get_Name_Index */
202+ /* FT_Load_Char */
203+ /* */
204+ /* FT_OPEN_MEMORY */
205+ /* FT_OPEN_STREAM */
206+ /* FT_OPEN_PATHNAME */
207+ /* FT_OPEN_DRIVER */
208+ /* FT_OPEN_PARAMS */
209+ /* */
210+ /* FT_LOAD_DEFAULT */
211+ /* FT_LOAD_RENDER */
212+ /* FT_LOAD_MONOCHROME */
213+ /* FT_LOAD_LINEAR_DESIGN */
214+ /* FT_LOAD_NO_SCALE */
215+ /* FT_LOAD_NO_HINTING */
216+ /* FT_LOAD_NO_BITMAP */
217+ /* FT_LOAD_NO_AUTOHINT */
218+ /* FT_LOAD_COLOR */
219+ /* */
220+ /* FT_LOAD_VERTICAL_LAYOUT */
221+ /* FT_LOAD_IGNORE_TRANSFORM */
222+ /* FT_LOAD_FORCE_AUTOHINT */
223+ /* FT_LOAD_NO_RECURSE */
224+ /* FT_LOAD_PEDANTIC */
225+ /* */
226+ /* FT_LOAD_TARGET_NORMAL */
227+ /* FT_LOAD_TARGET_LIGHT */
228+ /* FT_LOAD_TARGET_MONO */
229+ /* FT_LOAD_TARGET_LCD */
230+ /* FT_LOAD_TARGET_LCD_V */
231+ /* */
232+ /* FT_LOAD_TARGET_MODE */
233+ /* */
234+ /* FT_Render_Glyph */
235+ /* FT_Render_Mode */
236+ /* FT_Get_Kerning */
237+ /* FT_Kerning_Mode */
238+ /* FT_Get_Track_Kerning */
239+ /* FT_Get_Glyph_Name */
240+ /* FT_Get_Postscript_Name */
241+ /* */
242+ /* FT_CharMapRec */
243+ /* FT_Select_Charmap */
244+ /* FT_Set_Charmap */
245+ /* FT_Get_Charmap_Index */
246+ /* */
247+ /* FT_Get_FSType_Flags */
248+ /* FT_Get_SubGlyph_Info */
249+ /* */
250+ /* FT_Face_Internal */
251+ /* FT_Size_Internal */
252+ /* FT_Slot_Internal */
253+ /* */
254+ /* FT_FACE_FLAG_XXX */
255+ /* FT_STYLE_FLAG_XXX */
256+ /* FT_OPEN_XXX */
257+ /* FT_LOAD_XXX */
258+ /* FT_LOAD_TARGET_XXX */
259+ /* FT_SUBGLYPH_FLAG_XXX */
260+ /* FT_FSTYPE_XXX */
261+ /* */
262+ /* FT_HAS_FAST_GLYPHS */
263+ /* */
264+ /*************************************************************************/
265+
266+
267+ /*************************************************************************/
268+ /* */
269+ /* <Struct> */
270+ /* FT_Glyph_Metrics */
271+ /* */
272+ /* <Description> */
273+ /* A structure to model the metrics of a single glyph. The values */
274+ /* are expressed in 26.6 fractional pixel format; if the flag */
275+ /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */
276+ /* are expressed in font units instead. */
277+ /* */
278+ /* <Fields> */
279+ /* width :: */
280+ /* The glyph's width. */
281+ /* */
282+ /* height :: */
283+ /* The glyph's height. */
284+ /* */
285+ /* horiBearingX :: */
286+ /* Left side bearing for horizontal layout. */
287+ /* */
288+ /* horiBearingY :: */
289+ /* Top side bearing for horizontal layout. */
290+ /* */
291+ /* horiAdvance :: */
292+ /* Advance width for horizontal layout. */
293+ /* */
294+ /* vertBearingX :: */
295+ /* Left side bearing for vertical layout. */
296+ /* */
297+ /* vertBearingY :: */
298+ /* Top side bearing for vertical layout. Larger positive values */
299+ /* mean further below the vertical glyph origin. */
300+ /* */
301+ /* vertAdvance :: */
302+ /* Advance height for vertical layout. Positive values mean the */
303+ /* glyph has a positive advance downward. */
304+ /* */
305+ /* <Note> */
306+ /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */
307+ /* dimensions of the hinted glyph (in case hinting is applicable). */
308+ /* */
309+ /* Stroking a glyph with an outside border does not increase */
310+ /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */
311+ /* values to account for the added width and height. */
312+ /* */
313+ /* FreeType doesn't use the `VORG' table data for CFF fonts because */
314+ /* it doesn't have an interface to quickly retrieve the glyph height. */
315+ /* The y~coordinate of the vertical origin can be simply computed as */
316+ /* `vertBearingY + height' after loading a glyph. */
317+ /* */
318+ typedef struct FT_Glyph_Metrics_
319+ {
320+ FT_Pos width;
321+ FT_Pos height;
322+
323+ FT_Pos horiBearingX;
324+ FT_Pos horiBearingY;
325+ FT_Pos horiAdvance;
326+
327+ FT_Pos vertBearingX;
328+ FT_Pos vertBearingY;
329+ FT_Pos vertAdvance;
330+
331+ } FT_Glyph_Metrics;
332+
333+
334+ /*************************************************************************/
335+ /* */
336+ /* <Struct> */
337+ /* FT_Bitmap_Size */
338+ /* */
339+ /* <Description> */
340+ /* This structure models the metrics of a bitmap strike (i.e., a set */
341+ /* of glyphs for a given point size and resolution) in a bitmap font. */
342+ /* It is used for the `available_sizes' field of @FT_Face. */
343+ /* */
344+ /* <Fields> */
345+ /* height :: The vertical distance, in pixels, between two */
346+ /* consecutive baselines. It is always positive. */
347+ /* */
348+ /* width :: The average width, in pixels, of all glyphs in the */
349+ /* strike. */
350+ /* */
351+ /* size :: The nominal size of the strike in 26.6 fractional */
352+ /* points. This field is not very useful. */
353+ /* */
354+ /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */
355+ /* pixels. */
356+ /* */
357+ /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */
358+ /* pixels. */
359+ /* */
360+ /* <Note> */
361+ /* Windows FNT: */
362+ /* The nominal size given in a FNT font is not reliable. If the */
363+ /* driver finds it incorrect, it sets `size' to some calculated */
364+ /* values, and `x_ppem' and `y_ppem' to the pixel width and height */
365+ /* given in the font, respectively. */
366+ /* */
367+ /* TrueType embedded bitmaps: */
368+ /* `size', `width', and `height' values are not contained in the */
369+ /* bitmap strike itself. They are computed from the global font */
370+ /* parameters. */
371+ /* */
372+ typedef struct FT_Bitmap_Size_
373+ {
374+ FT_Short height;
375+ FT_Short width;
376+
377+ FT_Pos size;
378+
379+ FT_Pos x_ppem;
380+ FT_Pos y_ppem;
381+
382+ } FT_Bitmap_Size;
383+
384+
385+ /*************************************************************************/
386+ /*************************************************************************/
387+ /* */
388+ /* O B J E C T C L A S S E S */
389+ /* */
390+ /*************************************************************************/
391+ /*************************************************************************/
392+
393+ /*************************************************************************/
394+ /* */
395+ /* <Type> */
396+ /* FT_Library */
397+ /* */
398+ /* <Description> */
399+ /* A handle to a FreeType library instance. Each `library' is */
400+ /* completely independent from the others; it is the `root' of a set */
401+ /* of objects like fonts, faces, sizes, etc. */
402+ /* */
403+ /* It also embeds a memory manager (see @FT_Memory), as well as a */
404+ /* scan-line converter object (see @FT_Raster). */
405+ /* */
406+ /* In multi-threaded applications it is easiest to use one */
407+ /* `FT_Library' object per thread. In case this is too cumbersome, */
408+ /* a single `FT_Library' object across threads is possible also */
409+ /* (since FreeType version 2.5.6), as long as a mutex lock is used */
410+ /* around @FT_New_Face and @FT_Done_Face. */
411+ /* */
412+ /* <Note> */
413+ /* Library objects are normally created by @FT_Init_FreeType, and */
414+ /* destroyed with @FT_Done_FreeType. If you need reference-counting */
415+ /* (cf. @FT_Reference_Library), use @FT_New_Library and */
416+ /* @FT_Done_Library. */
417+ /* */
418+ typedef struct FT_LibraryRec_ *FT_Library;
419+
420+
421+ /*************************************************************************/
422+ /* */
423+ /* <Section> */
424+ /* module_management */
425+ /* */
426+ /*************************************************************************/
427+
428+ /*************************************************************************/
429+ /* */
430+ /* <Type> */
431+ /* FT_Module */
432+ /* */
433+ /* <Description> */
434+ /* A handle to a given FreeType module object. A module can be a */
435+ /* font driver, a renderer, or anything else that provides services */
436+ /* to the former. */
437+ /* */
438+ typedef struct FT_ModuleRec_* FT_Module;
439+
440+
441+ /*************************************************************************/
442+ /* */
443+ /* <Type> */
444+ /* FT_Driver */
445+ /* */
446+ /* <Description> */
447+ /* A handle to a given FreeType font driver object. A font driver */
448+ /* is a module capable of creating faces from font files. */
449+ /* */
450+ typedef struct FT_DriverRec_* FT_Driver;
451+
452+
453+ /*************************************************************************/
454+ /* */
455+ /* <Type> */
456+ /* FT_Renderer */
457+ /* */
458+ /* <Description> */
459+ /* A handle to a given FreeType renderer. A renderer is a module in */
460+ /* charge of converting a glyph's outline image to a bitmap. It */
461+ /* supports a single glyph image format, and one or more target */
462+ /* surface depths. */
463+ /* */
464+ typedef struct FT_RendererRec_* FT_Renderer;
465+
466+
467+ /*************************************************************************/
468+ /* */
469+ /* <Section> */
470+ /* base_interface */
471+ /* */
472+ /*************************************************************************/
473+
474+ /*************************************************************************/
475+ /* */
476+ /* <Type> */
477+ /* FT_Face */
478+ /* */
479+ /* <Description> */
480+ /* A handle to a typographic face object. A face object models a */
481+ /* given typeface, in a given style. */
482+ /* */
483+ /* <Note> */
484+ /* A face object also owns a single @FT_GlyphSlot object, as well */
485+ /* as one or more @FT_Size objects. */
486+ /* */
487+ /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */
488+ /* a given filepath or a custom input stream. */
489+ /* */
490+ /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */
491+ /* */
492+ /* An `FT_Face' object can only be safely used from one thread at a */
493+ /* time. Similarly, creation and destruction of `FT_Face' with the */
494+ /* same @FT_Library object can only be done from one thread at a */
495+ /* time. On the other hand, functions like @FT_Load_Glyph and its */
496+ /* siblings are thread-safe and do not need the lock to be held as */
497+ /* long as the same `FT_Face' object is not used from multiple */
498+ /* threads at the same time. */
499+ /* */
500+ /* <Also> */
501+ /* See @FT_FaceRec for the publicly accessible fields of a given face */
502+ /* object. */
503+ /* */
504+ typedef struct FT_FaceRec_* FT_Face;
505+
506+
507+ /*************************************************************************/
508+ /* */
509+ /* <Type> */
510+ /* FT_Size */
511+ /* */
512+ /* <Description> */
513+ /* A handle to an object that models a face scaled to a given */
514+ /* character size. */
515+ /* */
516+ /* <Note> */
517+ /* An @FT_Face has one _active_ @FT_Size object that is used by */
518+ /* functions like @FT_Load_Glyph to determine the scaling */
519+ /* transformation that in turn is used to load and hint glyphs and */
520+ /* metrics. */
521+ /* */
522+ /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */
523+ /* @FT_Request_Size or even @FT_Select_Size to change the content */
524+ /* (i.e., the scaling values) of the active @FT_Size. */
525+ /* */
526+ /* You can use @FT_New_Size to create additional size objects for a */
527+ /* given @FT_Face, but they won't be used by other functions until */
528+ /* you activate it through @FT_Activate_Size. Only one size can be */
529+ /* activated at any given time per face. */
530+ /* */
531+ /* <Also> */
532+ /* See @FT_SizeRec for the publicly accessible fields of a given size */
533+ /* object. */
534+ /* */
535+ typedef struct FT_SizeRec_* FT_Size;
536+
537+
538+ /*************************************************************************/
539+ /* */
540+ /* <Type> */
541+ /* FT_GlyphSlot */
542+ /* */
543+ /* <Description> */
544+ /* A handle to a given `glyph slot'. A slot is a container that can */
545+ /* hold any of the glyphs contained in its parent face. */
546+ /* */
547+ /* In other words, each time you call @FT_Load_Glyph or */
548+ /* @FT_Load_Char, the slot's content is erased by the new glyph data, */
549+ /* i.e., the glyph's metrics, its image (bitmap or outline), and */
550+ /* other control information. */
551+ /* */
552+ /* <Also> */
553+ /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */
554+ /* */
555+ typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
556+
557+
558+ /*************************************************************************/
559+ /* */
560+ /* <Type> */
561+ /* FT_CharMap */
562+ /* */
563+ /* <Description> */
564+ /* A handle to a character map (usually abbreviated to `charmap'). A */
565+ /* charmap is used to translate character codes in a given encoding */
566+ /* into glyph indexes for its parent's face. Some font formats may */
567+ /* provide several charmaps per font. */
568+ /* */
569+ /* Each face object owns zero or more charmaps, but only one of them */
570+ /* can be `active', providing the data used by @FT_Get_Char_Index or */
571+ /* @FT_Load_Char. */
572+ /* */
573+ /* The list of available charmaps in a face is available through the */
574+ /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */
575+ /* */
576+ /* The currently active charmap is available as `face->charmap'. */
577+ /* You should call @FT_Set_Charmap to change it. */
578+ /* */
579+ /* <Note> */
580+ /* When a new face is created (either through @FT_New_Face or */
581+ /* @FT_Open_Face), the library looks for a Unicode charmap within */
582+ /* the list and automatically activates it. If there is no Unicode */
583+ /* charmap, FreeType doesn't set an `active' charmap. */
584+ /* */
585+ /* <Also> */
586+ /* See @FT_CharMapRec for the publicly accessible fields of a given */
587+ /* character map. */
588+ /* */
589+ typedef struct FT_CharMapRec_* FT_CharMap;
590+
591+
592+ /*************************************************************************/
593+ /* */
594+ /* <Macro> */
595+ /* FT_ENC_TAG */
596+ /* */
597+ /* <Description> */
598+ /* This macro converts four-letter tags into an unsigned long. It is */
599+ /* used to define `encoding' identifiers (see @FT_Encoding). */
600+ /* */
601+ /* <Note> */
602+ /* Since many 16-bit compilers don't like 32-bit enumerations, you */
603+ /* should redefine this macro in case of problems to something like */
604+ /* this: */
605+ /* */
606+ /* { */
607+ /* #define FT_ENC_TAG( value, a, b, c, d ) value */
608+ /* } */
609+ /* */
610+ /* to get a simple enumeration without assigning special numbers. */
611+ /* */
612+
613+#ifndef FT_ENC_TAG
614+#define FT_ENC_TAG( value, a, b, c, d ) \
615+ value = ( ( (FT_UInt32)(a) << 24 ) | \
616+ ( (FT_UInt32)(b) << 16 ) | \
617+ ( (FT_UInt32)(c) << 8 ) | \
618+ (FT_UInt32)(d) )
619+
620+#endif /* FT_ENC_TAG */
621+
622+
623+ /*************************************************************************/
624+ /* */
625+ /* <Enum> */
626+ /* FT_Encoding */
627+ /* */
628+ /* <Description> */
629+ /* An enumeration to specify character sets supported by charmaps. */
630+ /* Used in the @FT_Select_Charmap API function. */
631+ /* */
632+ /* <Note> */
633+ /* Despite the name, this enumeration lists specific character */
634+ /* repertories (i.e., charsets), and not text encoding methods (e.g., */
635+ /* UTF-8, UTF-16, etc.). */
636+ /* */
637+ /* Other encodings might be defined in the future. */
638+ /* */
639+ /* <Values> */
640+ /* FT_ENCODING_NONE :: */
641+ /* The encoding value~0 is reserved. */
642+ /* */
643+ /* FT_ENCODING_UNICODE :: */
644+ /* The Unicode character set. This value covers all versions of */
645+ /* the Unicode repertoire, including ASCII and Latin-1. Most fonts */
646+ /* include a Unicode charmap, but not all of them. */
647+ /* */
648+ /* For example, if you want to access Unicode value U+1F028 (and */
649+ /* the font contains it), use value 0x1F028 as the input value for */
650+ /* @FT_Get_Char_Index. */
651+ /* */
652+ /* FT_ENCODING_MS_SYMBOL :: */
653+ /* Microsoft Symbol encoding, used to encode mathematical symbols */
654+ /* and wingdings. For more information, see */
655+ /* `https://www.microsoft.com/typography/otspec/recom.htm', */
656+ /* `http://www.kostis.net/charsets/symbol.htm', and */
657+ /* `http://www.kostis.net/charsets/wingding.htm'. */
658+ /* */
659+ /* This encoding uses character codes from the PUA (Private Unicode */
660+ /* Area) in the range U+F020-U+F0FF. */
661+ /* */
662+ /* FT_ENCODING_SJIS :: */
663+ /* Shift JIS encoding for Japanese. More info at */
664+ /* `https://en.wikipedia.org/wiki/Shift_JIS'. See note on */
665+ /* multi-byte encodings below. */
666+ /* */
667+ /* FT_ENCODING_PRC :: */
668+ /* Corresponds to encoding systems mainly for Simplified Chinese as */
669+ /* used in People's Republic of China (PRC). The encoding layout */
670+ /* is based on GB~2312 and its supersets GBK and GB~18030. */
671+ /* */
672+ /* FT_ENCODING_BIG5 :: */
673+ /* Corresponds to an encoding system for Traditional Chinese as */
674+ /* used in Taiwan and Hong Kong. */
675+ /* */
676+ /* FT_ENCODING_WANSUNG :: */
677+ /* Corresponds to the Korean encoding system known as Extended */
678+ /* Wansung (MS Windows code page 949). */
679+ /* For more information see */
680+ /* `https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. */
681+ /* */
682+ /* FT_ENCODING_JOHAB :: */
683+ /* The Korean standard character set (KS~C 5601-1992), which */
684+ /* corresponds to MS Windows code page 1361. This character set */
685+ /* includes all possible Hangul character combinations. */
686+ /* */
687+ /* FT_ENCODING_ADOBE_LATIN_1 :: */
688+ /* Corresponds to a Latin-1 encoding as defined in a Type~1 */
689+ /* PostScript font. It is limited to 256 character codes. */
690+ /* */
691+ /* FT_ENCODING_ADOBE_STANDARD :: */
692+ /* Adobe Standard encoding, as found in Type~1, CFF, and */
693+ /* OpenType/CFF fonts. It is limited to 256 character codes. */
694+ /* */
695+ /* FT_ENCODING_ADOBE_EXPERT :: */
696+ /* Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF */
697+ /* fonts. It is limited to 256 character codes. */
698+ /* */
699+ /* FT_ENCODING_ADOBE_CUSTOM :: */
700+ /* Corresponds to a custom encoding, as found in Type~1, CFF, and */
701+ /* OpenType/CFF fonts. It is limited to 256 character codes. */
702+ /* */
703+ /* FT_ENCODING_APPLE_ROMAN :: */
704+ /* Apple roman encoding. Many TrueType and OpenType fonts contain */
705+ /* a charmap for this 8-bit encoding, since older versions of Mac */
706+ /* OS are able to use it. */
707+ /* */
708+ /* FT_ENCODING_OLD_LATIN_2 :: */
709+ /* This value is deprecated and was neither used nor reported by */
710+ /* FreeType. Don't use or test for it. */
711+ /* */
712+ /* FT_ENCODING_MS_SJIS :: */
713+ /* Same as FT_ENCODING_SJIS. Deprecated. */
714+ /* */
715+ /* FT_ENCODING_MS_GB2312 :: */
716+ /* Same as FT_ENCODING_PRC. Deprecated. */
717+ /* */
718+ /* FT_ENCODING_MS_BIG5 :: */
719+ /* Same as FT_ENCODING_BIG5. Deprecated. */
720+ /* */
721+ /* FT_ENCODING_MS_WANSUNG :: */
722+ /* Same as FT_ENCODING_WANSUNG. Deprecated. */
723+ /* */
724+ /* FT_ENCODING_MS_JOHAB :: */
725+ /* Same as FT_ENCODING_JOHAB. Deprecated. */
726+ /* */
727+ /* <Note> */
728+ /* By default, FreeType enables a Unicode charmap and tags it with */
729+ /* FT_ENCODING_UNICODE when it is either provided or can be generated */
730+ /* from PostScript glyph name dictionaries in the font file. */
731+ /* All other encodings are considered legacy and tagged only if */
732+ /* explicitly defined in the font file. Otherwise, FT_ENCODING_NONE */
733+ /* is used. */
734+ /* */
735+ /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */
736+ /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */
737+ /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */
738+ /* which encoding is really present. If, for example, the */
739+ /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */
740+ /* the font is encoded in KOI8-R. */
741+ /* */
742+ /* FT_ENCODING_NONE is always set (with a single exception) by the */
743+ /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */
744+ /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */
745+ /* which encoding is really present. For example, */
746+ /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */
747+ /* Russian). */
748+ /* */
749+ /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */
750+ /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */
751+ /* FT_ENCODING_APPLE_ROMAN). */
752+ /* */
753+ /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */
754+ /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */
755+ /* be needed to be able to distinguish Apple encoding variants. See */
756+ /* */
757+ /* https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */
758+ /* */
759+ /* to get an idea how to do that. Basically, if the language ID */
760+ /* is~0, don't use it, otherwise subtract 1 from the language ID. */
761+ /* Then examine `encoding_id'. If, for example, `encoding_id' is */
762+ /* `TT_MAC_ID_ROMAN' and the language ID (minus~1) is */
763+ /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */
764+ /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */
765+ /* variant the Arabic encoding. */
766+ /* */
767+ typedef enum FT_Encoding_
768+ {
769+ FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
770+
771+ FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
772+ FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
773+
774+ FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
775+ FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ),
776+ FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
777+ FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
778+ FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
779+
780+ /* for backward compatibility */
781+ FT_ENCODING_GB2312 = FT_ENCODING_PRC,
782+ FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
783+ FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
784+ FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
785+ FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
786+ FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
787+
788+ FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
789+ FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
790+ FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
791+ FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
792+
793+ FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
794+
795+ FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
796+
797+ } FT_Encoding;
798+
799+
800+ /* these constants are deprecated; use the corresponding `FT_Encoding' */
801+ /* values instead */
802+#define ft_encoding_none FT_ENCODING_NONE
803+#define ft_encoding_unicode FT_ENCODING_UNICODE
804+#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
805+#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
806+#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
807+#define ft_encoding_sjis FT_ENCODING_SJIS
808+#define ft_encoding_gb2312 FT_ENCODING_PRC
809+#define ft_encoding_big5 FT_ENCODING_BIG5
810+#define ft_encoding_wansung FT_ENCODING_WANSUNG
811+#define ft_encoding_johab FT_ENCODING_JOHAB
812+
813+#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
814+#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
815+#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
816+#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
817+
818+
819+ /*************************************************************************/
820+ /* */
821+ /* <Struct> */
822+ /* FT_CharMapRec */
823+ /* */
824+ /* <Description> */
825+ /* The base charmap structure. */
826+ /* */
827+ /* <Fields> */
828+ /* face :: A handle to the parent face object. */
829+ /* */
830+ /* encoding :: An @FT_Encoding tag identifying the charmap. Use */
831+ /* this with @FT_Select_Charmap. */
832+ /* */
833+ /* platform_id :: An ID number describing the platform for the */
834+ /* following encoding ID. This comes directly from */
835+ /* the TrueType specification and gets emulated for */
836+ /* other formats. */
837+ /* */
838+ /* encoding_id :: A platform specific encoding number. This also */
839+ /* comes from the TrueType specification and gets */
840+ /* emulated similarly. */
841+ /* */
842+ typedef struct FT_CharMapRec_
843+ {
844+ FT_Face face;
845+ FT_Encoding encoding;
846+ FT_UShort platform_id;
847+ FT_UShort encoding_id;
848+
849+ } FT_CharMapRec;
850+
851+
852+ /*************************************************************************/
853+ /*************************************************************************/
854+ /* */
855+ /* B A S E O B J E C T C L A S S E S */
856+ /* */
857+ /*************************************************************************/
858+ /*************************************************************************/
859+
860+
861+ /*************************************************************************/
862+ /* */
863+ /* <Type> */
864+ /* FT_Face_Internal */
865+ /* */
866+ /* <Description> */
867+ /* An opaque handle to an `FT_Face_InternalRec' structure that models */
868+ /* the private data of a given @FT_Face object. */
869+ /* */
870+ /* This structure might change between releases of FreeType~2 and is */
871+ /* not generally available to client applications. */
872+ /* */
873+ typedef struct FT_Face_InternalRec_* FT_Face_Internal;
874+
875+
876+ /*************************************************************************/
877+ /* */
878+ /* <Struct> */
879+ /* FT_FaceRec */
880+ /* */
881+ /* <Description> */
882+ /* FreeType root face class structure. A face object models a */
883+ /* typeface in a font file. */
884+ /* */
885+ /* <Fields> */
886+ /* num_faces :: The number of faces in the font file. Some */
887+ /* font formats can have multiple faces in */
888+ /* a single font file. */
889+ /* */
890+ /* face_index :: This field holds two different values. */
891+ /* Bits 0-15 are the index of the face in the */
892+ /* font file (starting with value~0). They */
893+ /* are set to~0 if there is only one face in */
894+ /* the font file. */
895+ /* */
896+ /* [Since 2.6.1] Bits 16-30 are relevant to GX */
897+ /* and OpenType variation fonts only, holding */
898+ /* the named instance index for the current */
899+ /* face index (starting with value~1; value~0 */
900+ /* indicates font access without a named */
901+ /* instance). For non-variation fonts, bits */
902+ /* 16-30 are ignored. If we have the third */
903+ /* named instance of face~4, say, `face_index' */
904+ /* is set to 0x00030004. */
905+ /* */
906+ /* Bit 31 is always zero (this is, */
907+ /* `face_index' is always a positive value). */
908+ /* */
909+ /* [Since 2.9] Changing the design coordinates */
910+ /* with @FT_Set_Var_Design_Coordinates or */
911+ /* @FT_Set_Var_Blend_Coordinates does not */
912+ /* influence the named instance index value */
913+ /* (only @FT_Set_Named_Instance does that). */
914+ /* */
915+ /* face_flags :: A set of bit flags that give important */
916+ /* information about the face; see */
917+ /* @FT_FACE_FLAG_XXX for the details. */
918+ /* */
919+ /* style_flags :: The lower 16~bits contain a set of bit */
920+ /* flags indicating the style of the face; see */
921+ /* @FT_STYLE_FLAG_XXX for the details. */
922+ /* */
923+ /* [Since 2.6.1] Bits 16-30 hold the number */
924+ /* of named instances available for the */
925+ /* current face if we have a GX or OpenType */
926+ /* variation (sub)font. Bit 31 is always zero */
927+ /* (this is, `style_flags' is always a */
928+ /* positive value). Note that a variation */
929+ /* font has always at least one named */
930+ /* instance, namely the default instance. */
931+ /* */
932+ /* num_glyphs :: The number of glyphs in the face. If the */
933+ /* face is scalable and has sbits (see */
934+ /* `num_fixed_sizes'), it is set to the number */
935+ /* of outline glyphs. */
936+ /* */
937+ /* For CID-keyed fonts (not in an SFNT */
938+ /* wrapper) this value gives the highest CID */
939+ /* used in the font. */
940+ /* */
941+ /* family_name :: The face's family name. This is an ASCII */
942+ /* string, usually in English, that describes */
943+ /* the typeface's family (like `Times New */
944+ /* Roman', `Bodoni', `Garamond', etc). This */
945+ /* is a least common denominator used to list */
946+ /* fonts. Some formats (TrueType & OpenType) */
947+ /* provide localized and Unicode versions of */
948+ /* this string. Applications should use the */
949+ /* format specific interface to access them. */
950+ /* Can be NULL (e.g., in fonts embedded in a */
951+ /* PDF file). */
952+ /* */
953+ /* In case the font doesn't provide a specific */
954+ /* family name entry, FreeType tries to */
955+ /* synthesize one, deriving it from other name */
956+ /* entries. */
957+ /* */
958+ /* style_name :: The face's style name. This is an ASCII */
959+ /* string, usually in English, that describes */
960+ /* the typeface's style (like `Italic', */
961+ /* `Bold', `Condensed', etc). Not all font */
962+ /* formats provide a style name, so this field */
963+ /* is optional, and can be set to NULL. As */
964+ /* for `family_name', some formats provide */
965+ /* localized and Unicode versions of this */
966+ /* string. Applications should use the format */
967+ /* specific interface to access them. */
968+ /* */
969+ /* num_fixed_sizes :: The number of bitmap strikes in the face. */
970+ /* Even if the face is scalable, there might */
971+ /* still be bitmap strikes, which are called */
972+ /* `sbits' in that case. */
973+ /* */
974+ /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */
975+ /* strikes in the face. It is set to NULL if */
976+ /* there is no bitmap strike. */
977+ /* */
978+ /* Note that FreeType tries to sanitize the */
979+ /* strike data since they are sometimes sloppy */
980+ /* or incorrect, but this can easily fail. */
981+ /* */
982+ /* num_charmaps :: The number of charmaps in the face. */
983+ /* */
984+ /* charmaps :: An array of the charmaps of the face. */
985+ /* */
986+ /* generic :: A field reserved for client uses. See the */
987+ /* @FT_Generic type description. */
988+ /* */
989+ /* bbox :: The font bounding box. Coordinates are */
990+ /* expressed in font units (see */
991+ /* `units_per_EM'). The box is large enough */
992+ /* to contain any glyph from the font. Thus, */
993+ /* `bbox.yMax' can be seen as the `maximum */
994+ /* ascender', and `bbox.yMin' as the `minimum */
995+ /* descender'. Only relevant for scalable */
996+ /* formats. */
997+ /* */
998+ /* Note that the bounding box might be off by */
999+ /* (at least) one pixel for hinted fonts. See */
1000+ /* @FT_Size_Metrics for further discussion. */
1001+ /* */
1002+ /* units_per_EM :: The number of font units per EM square for */
1003+ /* this face. This is typically 2048 for */
1004+ /* TrueType fonts, and 1000 for Type~1 fonts. */
1005+ /* Only relevant for scalable formats. */
1006+ /* */
1007+ /* ascender :: The typographic ascender of the face, */
1008+ /* expressed in font units. For font formats */
1009+ /* not having this information, it is set to */
1010+ /* `bbox.yMax'. Only relevant for scalable */
1011+ /* formats. */
1012+ /* */
1013+ /* descender :: The typographic descender of the face, */
1014+ /* expressed in font units. For font formats */
1015+ /* not having this information, it is set to */
1016+ /* `bbox.yMin'. Note that this field is */
1017+ /* negative for values below the baseline. */
1018+ /* Only relevant for scalable formats. */
1019+ /* */
1020+ /* height :: This value is the vertical distance */
1021+ /* between two consecutive baselines, */
1022+ /* expressed in font units. It is always */
1023+ /* positive. Only relevant for scalable */
1024+ /* formats. */
1025+ /* */
1026+ /* If you want the global glyph height, use */
1027+ /* `ascender - descender'. */
1028+ /* */
1029+ /* max_advance_width :: The maximum advance width, in font units, */
1030+ /* for all glyphs in this face. This can be */
1031+ /* used to make word wrapping computations */
1032+ /* faster. Only relevant for scalable */
1033+ /* formats. */
1034+ /* */
1035+ /* max_advance_height :: The maximum advance height, in font units, */
1036+ /* for all glyphs in this face. This is only */
1037+ /* relevant for vertical layouts, and is set */
1038+ /* to `height' for fonts that do not provide */
1039+ /* vertical metrics. Only relevant for */
1040+ /* scalable formats. */
1041+ /* */
1042+ /* underline_position :: The position, in font units, of the */
1043+ /* underline line for this face. It is the */
1044+ /* center of the underlining stem. Only */
1045+ /* relevant for scalable formats. */
1046+ /* */
1047+ /* underline_thickness :: The thickness, in font units, of the */
1048+ /* underline for this face. Only relevant for */
1049+ /* scalable formats. */
1050+ /* */
1051+ /* glyph :: The face's associated glyph slot(s). */
1052+ /* */
1053+ /* size :: The current active size for this face. */
1054+ /* */
1055+ /* charmap :: The current active charmap for this face. */
1056+ /* */
1057+ /* <Note> */
1058+ /* Fields may be changed after a call to @FT_Attach_File or */
1059+ /* @FT_Attach_Stream. */
1060+ /* */
1061+ /* For an OpenType variation font, the values of the following fields */
1062+ /* can change after a call to @FT_Set_Var_Design_Coordinates (and */
1063+ /* friends) if the font contains an `MVAR' table: `ascender', */
1064+ /* `descender', `height', `underline_position', and */
1065+ /* `underline_thickness'. */
1066+ /* */
1067+ /* Especially for TrueType fonts see also the documentation for */
1068+ /* @FT_Size_Metrics. */
1069+ /* */
1070+ typedef struct FT_FaceRec_
1071+ {
1072+ FT_Long num_faces;
1073+ FT_Long face_index;
1074+
1075+ FT_Long face_flags;
1076+ FT_Long style_flags;
1077+
1078+ FT_Long num_glyphs;
1079+
1080+ FT_String* family_name;
1081+ FT_String* style_name;
1082+
1083+ FT_Int num_fixed_sizes;
1084+ FT_Bitmap_Size* available_sizes;
1085+
1086+ FT_Int num_charmaps;
1087+ FT_CharMap* charmaps;
1088+
1089+ FT_Generic generic;
1090+
1091+ /*# The following member variables (down to `underline_thickness') */
1092+ /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
1093+ /*# for bitmap fonts. */
1094+ FT_BBox bbox;
1095+
1096+ FT_UShort units_per_EM;
1097+ FT_Short ascender;
1098+ FT_Short descender;
1099+ FT_Short height;
1100+
1101+ FT_Short max_advance_width;
1102+ FT_Short max_advance_height;
1103+
1104+ FT_Short underline_position;
1105+ FT_Short underline_thickness;
1106+
1107+ FT_GlyphSlot glyph;
1108+ FT_Size size;
1109+ FT_CharMap charmap;
1110+
1111+ /*@private begin */
1112+
1113+ FT_Driver driver;
1114+ FT_Memory memory;
1115+ FT_Stream stream;
1116+
1117+ FT_ListRec sizes_list;
1118+
1119+ FT_Generic autohint; /* face-specific auto-hinter data */
1120+ void* extensions; /* unused */
1121+
1122+ FT_Face_Internal internal;
1123+
1124+ /*@private end */
1125+
1126+ } FT_FaceRec;
1127+
1128+
1129+ /*************************************************************************/
1130+ /* */
1131+ /* <Enum> */
1132+ /* FT_FACE_FLAG_XXX */
1133+ /* */
1134+ /* <Description> */
1135+ /* A list of bit flags used in the `face_flags' field of the */
1136+ /* @FT_FaceRec structure. They inform client applications of */
1137+ /* properties of the corresponding face. */
1138+ /* */
1139+ /* <Values> */
1140+ /* FT_FACE_FLAG_SCALABLE :: */
1141+ /* The face contains outline glyphs. Note that a face can contain */
1142+ /* bitmap strikes also, i.e., a face can have both this flag and */
1143+ /* @FT_FACE_FLAG_FIXED_SIZES set. */
1144+ /* */
1145+ /* FT_FACE_FLAG_FIXED_SIZES :: */
1146+ /* The face contains bitmap strikes. See also the */
1147+ /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */
1148+ /* */
1149+ /* FT_FACE_FLAG_FIXED_WIDTH :: */
1150+ /* The face contains fixed-width characters (like Courier, Lucida, */
1151+ /* MonoType, etc.). */
1152+ /* */
1153+ /* FT_FACE_FLAG_SFNT :: */
1154+ /* The face uses the SFNT storage scheme. For now, this means */
1155+ /* TrueType and OpenType. */
1156+ /* */
1157+ /* FT_FACE_FLAG_HORIZONTAL :: */
1158+ /* The face contains horizontal glyph metrics. This should be set */
1159+ /* for all common formats. */
1160+ /* */
1161+ /* FT_FACE_FLAG_VERTICAL :: */
1162+ /* The face contains vertical glyph metrics. This is only */
1163+ /* available in some formats, not all of them. */
1164+ /* */
1165+ /* FT_FACE_FLAG_KERNING :: */
1166+ /* The face contains kerning information. If set, the kerning */
1167+ /* distance can be retrieved using the function @FT_Get_Kerning. */
1168+ /* Otherwise the function always return the vector (0,0). Note */
1169+ /* that FreeType doesn't handle kerning data from the SFNT `GPOS' */
1170+ /* table (as present in many OpenType fonts). */
1171+ /* */
1172+ /* FT_FACE_FLAG_FAST_GLYPHS :: */
1173+ /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */
1174+ /* */
1175+ /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */
1176+ /* The face contains multiple masters and is capable of */
1177+ /* interpolating between them. Supported formats are Adobe MM, */
1178+ /* TrueType GX, and OpenType variation fonts. */
1179+ /* */
1180+ /* See section @multiple_masters for API details. */
1181+ /* */
1182+ /* FT_FACE_FLAG_GLYPH_NAMES :: */
1183+ /* The face contains glyph names, which can be retrieved using */
1184+ /* @FT_Get_Glyph_Name. Note that some TrueType fonts contain */
1185+ /* broken glyph name tables. Use the function */
1186+ /* @FT_Has_PS_Glyph_Names when needed. */
1187+ /* */
1188+ /* FT_FACE_FLAG_EXTERNAL_STREAM :: */
1189+ /* Used internally by FreeType to indicate that a face's stream was */
1190+ /* provided by the client application and should not be destroyed */
1191+ /* when @FT_Done_Face is called. Don't read or test this flag. */
1192+ /* */
1193+ /* FT_FACE_FLAG_HINTER :: */
1194+ /* The font driver has a hinting machine of its own. For example, */
1195+ /* with TrueType fonts, it makes sense to use data from the SFNT */
1196+ /* `gasp' table only if the native TrueType hinting engine (with */
1197+ /* the bytecode interpreter) is available and active. */
1198+ /* */
1199+ /* FT_FACE_FLAG_CID_KEYED :: */
1200+ /* The face is CID-keyed. In that case, the face is not accessed */
1201+ /* by glyph indices but by CID values. For subsetted CID-keyed */
1202+ /* fonts this has the consequence that not all index values are a */
1203+ /* valid argument to @FT_Load_Glyph. Only the CID values for which */
1204+ /* corresponding glyphs in the subsetted font exist make */
1205+ /* `FT_Load_Glyph' return successfully; in all other cases you get */
1206+ /* an `FT_Err_Invalid_Argument' error. */
1207+ /* */
1208+ /* Note that CID-keyed fonts that are in an SFNT wrapper (this is, */
1209+ /* all OpenType/CFF fonts) don't have this flag set since the */
1210+ /* glyphs are accessed in the normal way (using contiguous */
1211+ /* indices); the `CID-ness' isn't visible to the application. */
1212+ /* */
1213+ /* FT_FACE_FLAG_TRICKY :: */
1214+ /* The face is `tricky', this is, it always needs the font format's */
1215+ /* native hinting engine to get a reasonable result. A typical */
1216+ /* example is the old Chinese font `mingli.ttf' (but not */
1217+ /* `mingliu.ttc') that uses TrueType bytecode instructions to move */
1218+ /* and scale all of its subglyphs. */
1219+ /* */
1220+ /* It is not possible to auto-hint such fonts using */
1221+ /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */
1222+ /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */
1223+ /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */
1224+ /* probably never want this except for demonstration purposes. */
1225+ /* */
1226+ /* Currently, there are about a dozen TrueType fonts in the list of */
1227+ /* tricky fonts; they are hard-coded in file `ttobjs.c'. */
1228+ /* */
1229+ /* FT_FACE_FLAG_COLOR :: */
1230+ /* [Since 2.5.1] The face has color glyph tables. To access color */
1231+ /* glyphs use @FT_LOAD_COLOR. */
1232+ /* */
1233+ /* FT_FACE_FLAG_VARIATION :: */
1234+ /* [Since 2.9] Set if the current face (or named instance) has been */
1235+ /* altered with @FT_Set_MM_Design_Coordinates, */
1236+ /* @FT_Set_Var_Design_Coordinates, or */
1237+ /* @FT_Set_Var_Blend_Coordinates. This flag is unset by a call to */
1238+ /* @FT_Set_Named_Instance. */
1239+ /* */
1240+#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
1241+#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
1242+#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
1243+#define FT_FACE_FLAG_SFNT ( 1L << 3 )
1244+#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
1245+#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
1246+#define FT_FACE_FLAG_KERNING ( 1L << 6 )
1247+#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
1248+#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
1249+#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
1250+#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
1251+#define FT_FACE_FLAG_HINTER ( 1L << 11 )
1252+#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
1253+#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
1254+#define FT_FACE_FLAG_COLOR ( 1L << 14 )
1255+#define FT_FACE_FLAG_VARIATION ( 1L << 15 )
1256+
1257+
1258+ /*************************************************************************
1259+ *
1260+ * @macro:
1261+ * FT_HAS_HORIZONTAL( face )
1262+ *
1263+ * @description:
1264+ * A macro that returns true whenever a face object contains
1265+ * horizontal metrics (this is true for all font formats though).
1266+ *
1267+ * @also:
1268+ * @FT_HAS_VERTICAL can be used to check for vertical metrics.
1269+ *
1270+ */
1271+#define FT_HAS_HORIZONTAL( face ) \
1272+ ( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL )
1273+
1274+
1275+ /*************************************************************************
1276+ *
1277+ * @macro:
1278+ * FT_HAS_VERTICAL( face )
1279+ *
1280+ * @description:
1281+ * A macro that returns true whenever a face object contains real
1282+ * vertical metrics (and not only synthesized ones).
1283+ *
1284+ */
1285+#define FT_HAS_VERTICAL( face ) \
1286+ ( (face)->face_flags & FT_FACE_FLAG_VERTICAL )
1287+
1288+
1289+ /*************************************************************************
1290+ *
1291+ * @macro:
1292+ * FT_HAS_KERNING( face )
1293+ *
1294+ * @description:
1295+ * A macro that returns true whenever a face object contains kerning
1296+ * data that can be accessed with @FT_Get_Kerning.
1297+ *
1298+ */
1299+#define FT_HAS_KERNING( face ) \
1300+ ( (face)->face_flags & FT_FACE_FLAG_KERNING )
1301+
1302+
1303+ /*************************************************************************
1304+ *
1305+ * @macro:
1306+ * FT_IS_SCALABLE( face )
1307+ *
1308+ * @description:
1309+ * A macro that returns true whenever a face object contains a scalable
1310+ * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF,
1311+ * and PFR font formats).
1312+ *
1313+ */
1314+#define FT_IS_SCALABLE( face ) \
1315+ ( (face)->face_flags & FT_FACE_FLAG_SCALABLE )
1316+
1317+
1318+ /*************************************************************************
1319+ *
1320+ * @macro:
1321+ * FT_IS_SFNT( face )
1322+ *
1323+ * @description:
1324+ * A macro that returns true whenever a face object contains a font
1325+ * whose format is based on the SFNT storage scheme. This usually
1326+ * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded
1327+ * bitmap fonts.
1328+ *
1329+ * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
1330+ * @FT_TRUETYPE_TABLES_H are available.
1331+ *
1332+ */
1333+#define FT_IS_SFNT( face ) \
1334+ ( (face)->face_flags & FT_FACE_FLAG_SFNT )
1335+
1336+
1337+ /*************************************************************************
1338+ *
1339+ * @macro:
1340+ * FT_IS_FIXED_WIDTH( face )
1341+ *
1342+ * @description:
1343+ * A macro that returns true whenever a face object contains a font face
1344+ * that contains fixed-width (or `monospace', `fixed-pitch', etc.)
1345+ * glyphs.
1346+ *
1347+ */
1348+#define FT_IS_FIXED_WIDTH( face ) \
1349+ ( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
1350+
1351+
1352+ /*************************************************************************
1353+ *
1354+ * @macro:
1355+ * FT_HAS_FIXED_SIZES( face )
1356+ *
1357+ * @description:
1358+ * A macro that returns true whenever a face object contains some
1359+ * embedded bitmaps. See the `available_sizes' field of the
1360+ * @FT_FaceRec structure.
1361+ *
1362+ */
1363+#define FT_HAS_FIXED_SIZES( face ) \
1364+ ( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES )
1365+
1366+
1367+ /*************************************************************************
1368+ *
1369+ * @macro:
1370+ * FT_HAS_FAST_GLYPHS( face )
1371+ *
1372+ * @description:
1373+ * Deprecated.
1374+ *
1375+ */
1376+#define FT_HAS_FAST_GLYPHS( face ) 0
1377+
1378+
1379+ /*************************************************************************
1380+ *
1381+ * @macro:
1382+ * FT_HAS_GLYPH_NAMES( face )
1383+ *
1384+ * @description:
1385+ * A macro that returns true whenever a face object contains some glyph
1386+ * names that can be accessed through @FT_Get_Glyph_Name.
1387+ *
1388+ */
1389+#define FT_HAS_GLYPH_NAMES( face ) \
1390+ ( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
1391+
1392+
1393+ /*************************************************************************
1394+ *
1395+ * @macro:
1396+ * FT_HAS_MULTIPLE_MASTERS( face )
1397+ *
1398+ * @description:
1399+ * A macro that returns true whenever a face object contains some
1400+ * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
1401+ * are then available to choose the exact design you want.
1402+ *
1403+ */
1404+#define FT_HAS_MULTIPLE_MASTERS( face ) \
1405+ ( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
1406+
1407+
1408+ /*************************************************************************
1409+ *
1410+ * @macro:
1411+ * FT_IS_NAMED_INSTANCE( face )
1412+ *
1413+ * @description:
1414+ * A macro that returns true whenever a face object is a named instance
1415+ * of a GX or OpenType variation font.
1416+ *
1417+ * [Since 2.9] Changing the design coordinates with
1418+ * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
1419+ * not influence the return value of this macro (only
1420+ * @FT_Set_Named_Instance does that).
1421+ *
1422+ * @since:
1423+ * 2.7
1424+ *
1425+ */
1426+#define FT_IS_NAMED_INSTANCE( face ) \
1427+ ( (face)->face_index & 0x7FFF0000L )
1428+
1429+
1430+ /*************************************************************************
1431+ *
1432+ * @macro:
1433+ * FT_IS_VARIATION( face )
1434+ *
1435+ * @description:
1436+ * A macro that returns true whenever a face object has been altered
1437+ * by @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or
1438+ * @FT_Set_Var_Blend_Coordinates.
1439+ *
1440+ * @since:
1441+ * 2.9
1442+ *
1443+ */
1444+#define FT_IS_VARIATION( face ) \
1445+ ( (face)->face_flags & FT_FACE_FLAG_VARIATION )
1446+
1447+
1448+ /*************************************************************************
1449+ *
1450+ * @macro:
1451+ * FT_IS_CID_KEYED( face )
1452+ *
1453+ * @description:
1454+ * A macro that returns true whenever a face object contains a CID-keyed
1455+ * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more
1456+ * details.
1457+ *
1458+ * If this macro is true, all functions defined in @FT_CID_H are
1459+ * available.
1460+ *
1461+ */
1462+#define FT_IS_CID_KEYED( face ) \
1463+ ( (face)->face_flags & FT_FACE_FLAG_CID_KEYED )
1464+
1465+
1466+ /*************************************************************************
1467+ *
1468+ * @macro:
1469+ * FT_IS_TRICKY( face )
1470+ *
1471+ * @description:
1472+ * A macro that returns true whenever a face represents a `tricky' font.
1473+ * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
1474+ *
1475+ */
1476+#define FT_IS_TRICKY( face ) \
1477+ ( (face)->face_flags & FT_FACE_FLAG_TRICKY )
1478+
1479+
1480+ /*************************************************************************
1481+ *
1482+ * @macro:
1483+ * FT_HAS_COLOR( face )
1484+ *
1485+ * @description:
1486+ * A macro that returns true whenever a face object contains
1487+ * tables for color glyphs.
1488+ *
1489+ * @since:
1490+ * 2.5.1
1491+ *
1492+ */
1493+#define FT_HAS_COLOR( face ) \
1494+ ( (face)->face_flags & FT_FACE_FLAG_COLOR )
1495+
1496+
1497+ /*************************************************************************/
1498+ /* */
1499+ /* <Const> */
1500+ /* FT_STYLE_FLAG_XXX */
1501+ /* */
1502+ /* <Description> */
1503+ /* A list of bit flags to indicate the style of a given face. These */
1504+ /* are used in the `style_flags' field of @FT_FaceRec. */
1505+ /* */
1506+ /* <Values> */
1507+ /* FT_STYLE_FLAG_ITALIC :: */
1508+ /* The face style is italic or oblique. */
1509+ /* */
1510+ /* FT_STYLE_FLAG_BOLD :: */
1511+ /* The face is bold. */
1512+ /* */
1513+ /* <Note> */
1514+ /* The style information as provided by FreeType is very basic. More */
1515+ /* details are beyond the scope and should be done on a higher level */
1516+ /* (for example, by analyzing various fields of the `OS/2' table in */
1517+ /* SFNT based fonts). */
1518+ /* */
1519+#define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
1520+#define FT_STYLE_FLAG_BOLD ( 1 << 1 )
1521+
1522+
1523+ /*************************************************************************/
1524+ /* */
1525+ /* <Type> */
1526+ /* FT_Size_Internal */
1527+ /* */
1528+ /* <Description> */
1529+ /* An opaque handle to an `FT_Size_InternalRec' structure, used to */
1530+ /* model private data of a given @FT_Size object. */
1531+ /* */
1532+ typedef struct FT_Size_InternalRec_* FT_Size_Internal;
1533+
1534+
1535+ /*************************************************************************/
1536+ /* */
1537+ /* <Struct> */
1538+ /* FT_Size_Metrics */
1539+ /* */
1540+ /* <Description> */
1541+ /* The size metrics structure gives the metrics of a size object. */
1542+ /* */
1543+ /* <Fields> */
1544+ /* x_ppem :: The width of the scaled EM square in pixels, hence */
1545+ /* the term `ppem' (pixels per EM). It is also */
1546+ /* referred to as `nominal width'. */
1547+ /* */
1548+ /* y_ppem :: The height of the scaled EM square in pixels, */
1549+ /* hence the term `ppem' (pixels per EM). It is also */
1550+ /* referred to as `nominal height'. */
1551+ /* */
1552+ /* x_scale :: A 16.16 fractional scaling value to convert */
1553+ /* horizontal metrics from font units to 26.6 */
1554+ /* fractional pixels. Only relevant for scalable */
1555+ /* font formats. */
1556+ /* */
1557+ /* y_scale :: A 16.16 fractional scaling value to convert */
1558+ /* vertical metrics from font units to 26.6 */
1559+ /* fractional pixels. Only relevant for scalable */
1560+ /* font formats. */
1561+ /* */
1562+ /* ascender :: The ascender in 26.6 fractional pixels, rounded up */
1563+ /* to an integer value. See @FT_FaceRec for the */
1564+ /* details. */
1565+ /* */
1566+ /* descender :: The descender in 26.6 fractional pixels, rounded */
1567+ /* down to an integer value. See @FT_FaceRec for the */
1568+ /* details. */
1569+ /* */
1570+ /* height :: The height in 26.6 fractional pixels, rounded to */
1571+ /* an integer value. See @FT_FaceRec for the */
1572+ /* details. */
1573+ /* */
1574+ /* max_advance :: The maximum advance width in 26.6 fractional */
1575+ /* pixels, rounded to an integer value. See */
1576+ /* @FT_FaceRec for the details. */
1577+ /* */
1578+ /* <Note> */
1579+ /* The scaling values, if relevant, are determined first during a */
1580+ /* size changing operation. The remaining fields are then set by the */
1581+ /* driver. For scalable formats, they are usually set to scaled */
1582+ /* values of the corresponding fields in @FT_FaceRec. Some values */
1583+ /* like ascender or descender are rounded for historical reasons; */
1584+ /* more precise values (for outline fonts) can be derived by scaling */
1585+ /* the corresponding @FT_FaceRec values manually, with code similar */
1586+ /* to the following. */
1587+ /* */
1588+ /* { */
1589+ /* scaled_ascender = FT_MulFix( face->ascender, */
1590+ /* size_metrics->y_scale ); */
1591+ /* } */
1592+ /* */
1593+ /* Note that due to glyph hinting and the selected rendering mode */
1594+ /* these values are usually not exact; consequently, they must be */
1595+ /* treated as unreliable with an error margin of at least one pixel! */
1596+ /* */
1597+ /* Indeed, the only way to get the exact metrics is to render _all_ */
1598+ /* glyphs. As this would be a definite performance hit, it is up to */
1599+ /* client applications to perform such computations. */
1600+ /* */
1601+ /* The `FT_Size_Metrics' structure is valid for bitmap fonts also. */
1602+ /* */
1603+ /* */
1604+ /* *TrueType* *fonts* *with* *native* *bytecode* *hinting* */
1605+ /* */
1606+ /* All applications that handle TrueType fonts with native hinting */
1607+ /* must be aware that TTFs expect different rounding of vertical font */
1608+ /* dimensions. The application has to cater for this, especially if */
1609+ /* it wants to rely on a TTF's vertical data (for example, to */
1610+ /* properly align box characters vertically). */
1611+ /* */
1612+ /* Only the application knows _in_ _advance_ that it is going to use */
1613+ /* native hinting for TTFs! FreeType, on the other hand, selects the */
1614+ /* hinting mode not at the time of creating an @FT_Size object but */
1615+ /* much later, namely while calling @FT_Load_Glyph. */
1616+ /* */
1617+ /* Here is some pseudo code that illustrates a possible solution. */
1618+ /* */
1619+ /* { */
1620+ /* font_format = FT_Get_Font_Format( face ); */
1621+ /* */
1622+ /* if ( !strcmp( font_format, "TrueType" ) && */
1623+ /* do_native_bytecode_hinting ) */
1624+ /* { */
1625+ /* ascender = ROUND( FT_MulFix( face->ascender, */
1626+ /* size_metrics->y_scale ) ); */
1627+ /* descender = ROUND( FT_MulFix( face->descender, */
1628+ /* size_metrics->y_scale ) ); */
1629+ /* } */
1630+ /* else */
1631+ /* { */
1632+ /* ascender = size_metrics->ascender; */
1633+ /* descender = size_metrics->descender; */
1634+ /* } */
1635+ /* */
1636+ /* height = size_metrics->height; */
1637+ /* max_advance = size_metrics->max_advance; */
1638+ /* } */
1639+ /* */
1640+ typedef struct FT_Size_Metrics_
1641+ {
1642+ FT_UShort x_ppem; /* horizontal pixels per EM */
1643+ FT_UShort y_ppem; /* vertical pixels per EM */
1644+
1645+ FT_Fixed x_scale; /* scaling values used to convert font */
1646+ FT_Fixed y_scale; /* units to 26.6 fractional pixels */
1647+
1648+ FT_Pos ascender; /* ascender in 26.6 frac. pixels */
1649+ FT_Pos descender; /* descender in 26.6 frac. pixels */
1650+ FT_Pos height; /* text height in 26.6 frac. pixels */
1651+ FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
1652+
1653+ } FT_Size_Metrics;
1654+
1655+
1656+ /*************************************************************************/
1657+ /* */
1658+ /* <Struct> */
1659+ /* FT_SizeRec */
1660+ /* */
1661+ /* <Description> */
1662+ /* FreeType root size class structure. A size object models a face */
1663+ /* object at a given size. */
1664+ /* */
1665+ /* <Fields> */
1666+ /* face :: Handle to the parent face object. */
1667+ /* */
1668+ /* generic :: A typeless pointer, unused by the FreeType library or */
1669+ /* any of its drivers. It can be used by client */
1670+ /* applications to link their own data to each size */
1671+ /* object. */
1672+ /* */
1673+ /* metrics :: Metrics for this size object. This field is read-only. */
1674+ /* */
1675+ typedef struct FT_SizeRec_
1676+ {
1677+ FT_Face face; /* parent face object */
1678+ FT_Generic generic; /* generic pointer for client uses */
1679+ FT_Size_Metrics metrics; /* size metrics */
1680+ FT_Size_Internal internal;
1681+
1682+ } FT_SizeRec;
1683+
1684+
1685+ /*************************************************************************/
1686+ /* */
1687+ /* <Struct> */
1688+ /* FT_SubGlyph */
1689+ /* */
1690+ /* <Description> */
1691+ /* The subglyph structure is an internal object used to describe */
1692+ /* subglyphs (for example, in the case of composites). */
1693+ /* */
1694+ /* <Note> */
1695+ /* The subglyph implementation is not part of the high-level API, */
1696+ /* hence the forward structure declaration. */
1697+ /* */
1698+ /* You can however retrieve subglyph information with */
1699+ /* @FT_Get_SubGlyph_Info. */
1700+ /* */
1701+ typedef struct FT_SubGlyphRec_* FT_SubGlyph;
1702+
1703+
1704+ /*************************************************************************/
1705+ /* */
1706+ /* <Type> */
1707+ /* FT_Slot_Internal */
1708+ /* */
1709+ /* <Description> */
1710+ /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */
1711+ /* model private data of a given @FT_GlyphSlot object. */
1712+ /* */
1713+ typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
1714+
1715+
1716+ /*************************************************************************/
1717+ /* */
1718+ /* <Struct> */
1719+ /* FT_GlyphSlotRec */
1720+ /* */
1721+ /* <Description> */
1722+ /* FreeType root glyph slot class structure. A glyph slot is a */
1723+ /* container where individual glyphs can be loaded, be they in */
1724+ /* outline or bitmap format. */
1725+ /* */
1726+ /* <Fields> */
1727+ /* library :: A handle to the FreeType library instance */
1728+ /* this slot belongs to. */
1729+ /* */
1730+ /* face :: A handle to the parent face object. */
1731+ /* */
1732+ /* next :: In some cases (like some font tools), several */
1733+ /* glyph slots per face object can be a good */
1734+ /* thing. As this is rare, the glyph slots are */
1735+ /* listed through a direct, single-linked list */
1736+ /* using its `next' field. */
1737+ /* */
1738+ /* generic :: A typeless pointer unused by the FreeType */
1739+ /* library or any of its drivers. It can be */
1740+ /* used by client applications to link their own */
1741+ /* data to each glyph slot object. */
1742+ /* */
1743+ /* metrics :: The metrics of the last loaded glyph in the */
1744+ /* slot. The returned values depend on the last */
1745+ /* load flags (see the @FT_Load_Glyph API */
1746+ /* function) and can be expressed either in 26.6 */
1747+ /* fractional pixels or font units. */
1748+ /* */
1749+ /* Note that even when the glyph image is */
1750+ /* transformed, the metrics are not. */
1751+ /* */
1752+ /* linearHoriAdvance :: The advance width of the unhinted glyph. */
1753+ /* Its value is expressed in 16.16 fractional */
1754+ /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
1755+ /* when loading the glyph. This field can be */
1756+ /* important to perform correct WYSIWYG layout. */
1757+ /* Only relevant for outline glyphs. */
1758+ /* */
1759+ /* linearVertAdvance :: The advance height of the unhinted glyph. */
1760+ /* Its value is expressed in 16.16 fractional */
1761+ /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
1762+ /* when loading the glyph. This field can be */
1763+ /* important to perform correct WYSIWYG layout. */
1764+ /* Only relevant for outline glyphs. */
1765+ /* */
1766+ /* advance :: This shorthand is, depending on */
1767+ /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */
1768+ /* (hinted) advance width for the glyph, in 26.6 */
1769+ /* fractional pixel format. As specified with */
1770+ /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */
1771+ /* `horiAdvance' or the `vertAdvance' value of */
1772+ /* `metrics' field. */
1773+ /* */
1774+ /* format :: This field indicates the format of the image */
1775+ /* contained in the glyph slot. Typically */
1776+ /* @FT_GLYPH_FORMAT_BITMAP, */
1777+ /* @FT_GLYPH_FORMAT_OUTLINE, or */
1778+ /* @FT_GLYPH_FORMAT_COMPOSITE, but other values */
1779+ /* are possible. */
1780+ /* */
1781+ /* bitmap :: This field is used as a bitmap descriptor. */
1782+ /* Note that the address and content of the */
1783+ /* bitmap buffer can change between calls of */
1784+ /* @FT_Load_Glyph and a few other functions. */
1785+ /* */
1786+ /* bitmap_left :: The bitmap's left bearing expressed in */
1787+ /* integer pixels. */
1788+ /* */
1789+ /* bitmap_top :: The bitmap's top bearing expressed in integer */
1790+ /* pixels. This is the distance from the */
1791+ /* baseline to the top-most glyph scanline, */
1792+ /* upwards y~coordinates being *positive*. */
1793+ /* */
1794+ /* outline :: The outline descriptor for the current glyph */
1795+ /* image if its format is */
1796+ /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */
1797+ /* loaded, `outline' can be transformed, */
1798+ /* distorted, emboldened, etc. However, it must */
1799+ /* not be freed. */
1800+ /* */
1801+ /* num_subglyphs :: The number of subglyphs in a composite glyph. */
1802+ /* This field is only valid for the composite */
1803+ /* glyph format that should normally only be */
1804+ /* loaded with the @FT_LOAD_NO_RECURSE flag. */
1805+ /* */
1806+ /* subglyphs :: An array of subglyph descriptors for */
1807+ /* composite glyphs. There are `num_subglyphs' */
1808+ /* elements in there. Currently internal to */
1809+ /* FreeType. */
1810+ /* */
1811+ /* control_data :: Certain font drivers can also return the */
1812+ /* control data for a given glyph image (e.g. */
1813+ /* TrueType bytecode, Type~1 charstrings, etc.). */
1814+ /* This field is a pointer to such data; it is */
1815+ /* currently internal to FreeType. */
1816+ /* */
1817+ /* control_len :: This is the length in bytes of the control */
1818+ /* data. Currently internal to FreeType. */
1819+ /* */
1820+ /* other :: Reserved. */
1821+ /* */
1822+ /* lsb_delta :: The difference between hinted and unhinted */
1823+ /* left side bearing while auto-hinting is */
1824+ /* active. Zero otherwise. */
1825+ /* */
1826+ /* rsb_delta :: The difference between hinted and unhinted */
1827+ /* right side bearing while auto-hinting is */
1828+ /* active. Zero otherwise. */
1829+ /* */
1830+ /* <Note> */
1831+ /* If @FT_Load_Glyph is called with default flags (see */
1832+ /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
1833+ /* its native format (e.g., an outline glyph for TrueType and Type~1 */
1834+ /* formats). [Since 2.9] The prospective bitmap metrics are */
1835+ /* calculated according to @FT_LOAD_TARGET_XXX and other flags even */
1836+ /* for the outline glyph, even if @FT_LOAD_RENDER is not set. */
1837+ /* */
1838+ /* This image can later be converted into a bitmap by calling */
1839+ /* @FT_Render_Glyph. This function searches the current renderer for */
1840+ /* the native image's format, then invokes it. */
1841+ /* */
1842+ /* The renderer is in charge of transforming the native image through */
1843+ /* the slot's face transformation fields, then converting it into a */
1844+ /* bitmap that is returned in `slot->bitmap'. */
1845+ /* */
1846+ /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
1847+ /* to specify the position of the bitmap relative to the current pen */
1848+ /* position (e.g., coordinates (0,0) on the baseline). Of course, */
1849+ /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */
1850+ /* */
1851+ /* Here is a small pseudo code fragment that shows how to use */
1852+ /* `lsb_delta' and `rsb_delta' to do fractional positioning of */
1853+ /* glyphs: */
1854+ /* */
1855+ /* { */
1856+ /* FT_GlyphSlot slot = face->glyph; */
1857+ /* FT_Pos origin_x = 0; */
1858+ /* */
1859+ /* */
1860+ /* for all glyphs do */
1861+ /* <load glyph with `FT_Load_Glyph'> */
1862+ /* */
1863+ /* FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); */
1864+ /* */
1865+ /* <save glyph image, or render glyph, or ...> */
1866+ /* */
1867+ /* <compute kern between current and next glyph */
1868+ /* and add it to `origin_x'> */
1869+ /* */
1870+ /* origin_x += slot->advance.x; */
1871+ /* origin_x += slot->rsb_delta - slot->lsb_delta; */
1872+ /* endfor */
1873+ /* } */
1874+ /* */
1875+ /* Here is another small pseudo code fragment that shows how to use */
1876+ /* `lsb_delta' and `rsb_delta' to improve integer positioning of */
1877+ /* glyphs: */
1878+ /* */
1879+ /* { */
1880+ /* FT_GlyphSlot slot = face->glyph; */
1881+ /* FT_Pos origin_x = 0; */
1882+ /* FT_Pos prev_rsb_delta = 0; */
1883+ /* */
1884+ /* */
1885+ /* for all glyphs do */
1886+ /* <compute kern between current and previous glyph */
1887+ /* and add it to `origin_x'> */
1888+ /* */
1889+ /* <load glyph with `FT_Load_Glyph'> */
1890+ /* */
1891+ /* if ( prev_rsb_delta - slot->lsb_delta > 32 ) */
1892+ /* origin_x -= 64; */
1893+ /* else if ( prev_rsb_delta - slot->lsb_delta < -31 ) */
1894+ /* origin_x += 64; */
1895+ /* */
1896+ /* prev_rsb_delta = slot->rsb_delta; */
1897+ /* */
1898+ /* <save glyph image, or render glyph, or ...> */
1899+ /* */
1900+ /* origin_x += slot->advance.x; */
1901+ /* endfor */
1902+ /* } */
1903+ /* */
1904+ /* If you use strong auto-hinting, you *must* apply these delta */
1905+ /* values! Otherwise you will experience far too large inter-glyph */
1906+ /* spacing at small rendering sizes in most cases. Note that it */
1907+ /* doesn't harm to use the above code for other hinting modes also, */
1908+ /* since the delta values are zero then. */
1909+ /* */
1910+ typedef struct FT_GlyphSlotRec_
1911+ {
1912+ FT_Library library;
1913+ FT_Face face;
1914+ FT_GlyphSlot next;
1915+ FT_UInt reserved; /* retained for binary compatibility */
1916+ FT_Generic generic;
1917+
1918+ FT_Glyph_Metrics metrics;
1919+ FT_Fixed linearHoriAdvance;
1920+ FT_Fixed linearVertAdvance;
1921+ FT_Vector advance;
1922+
1923+ FT_Glyph_Format format;
1924+
1925+ FT_Bitmap bitmap;
1926+ FT_Int bitmap_left;
1927+ FT_Int bitmap_top;
1928+
1929+ FT_Outline outline;
1930+
1931+ FT_UInt num_subglyphs;
1932+ FT_SubGlyph subglyphs;
1933+
1934+ void* control_data;
1935+ long control_len;
1936+
1937+ FT_Pos lsb_delta;
1938+ FT_Pos rsb_delta;
1939+
1940+ void* other;
1941+
1942+ FT_Slot_Internal internal;
1943+
1944+ } FT_GlyphSlotRec;
1945+
1946+
1947+ /*************************************************************************/
1948+ /*************************************************************************/
1949+ /* */
1950+ /* F U N C T I O N S */
1951+ /* */
1952+ /*************************************************************************/
1953+ /*************************************************************************/
1954+
1955+
1956+ /*************************************************************************/
1957+ /* */
1958+ /* <Function> */
1959+ /* FT_Init_FreeType */
1960+ /* */
1961+ /* <Description> */
1962+ /* Initialize a new FreeType library object. The set of modules */
1963+ /* that are registered by this function is determined at build time. */
1964+ /* */
1965+ /* <Output> */
1966+ /* alibrary :: A handle to a new library object. */
1967+ /* */
1968+ /* <Return> */
1969+ /* FreeType error code. 0~means success. */
1970+ /* */
1971+ /* <Note> */
1972+ /* In case you want to provide your own memory allocating routines, */
1973+ /* use @FT_New_Library instead, followed by a call to */
1974+ /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module) */
1975+ /* and @FT_Set_Default_Properties. */
1976+ /* */
1977+ /* See the documentation of @FT_Library and @FT_Face for */
1978+ /* multi-threading issues. */
1979+ /* */
1980+ /* If you need reference-counting (cf. @FT_Reference_Library), use */
1981+ /* @FT_New_Library and @FT_Done_Library. */
1982+ /* */
1983+ /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */
1984+ /* set, this function reads the `FREETYPE_PROPERTIES' environment */
1985+ /* variable to control driver properties. See section @properties */
1986+ /* for more. */
1987+ /* */
1988+ FT_EXPORT( FT_Error )
1989+ FT_Init_FreeType( FT_Library *alibrary );
1990+
1991+
1992+ /*************************************************************************/
1993+ /* */
1994+ /* <Function> */
1995+ /* FT_Done_FreeType */
1996+ /* */
1997+ /* <Description> */
1998+ /* Destroy a given FreeType library object and all of its children, */
1999+ /* including resources, drivers, faces, sizes, etc. */
2000+ /* */
2001+ /* <Input> */
2002+ /* library :: A handle to the target library object. */
2003+ /* */
2004+ /* <Return> */
2005+ /* FreeType error code. 0~means success. */
2006+ /* */
2007+ FT_EXPORT( FT_Error )
2008+ FT_Done_FreeType( FT_Library library );
2009+
2010+
2011+ /*************************************************************************/
2012+ /* */
2013+ /* <Enum> */
2014+ /* FT_OPEN_XXX */
2015+ /* */
2016+ /* <Description> */
2017+ /* A list of bit field constants used within the `flags' field of the */
2018+ /* @FT_Open_Args structure. */
2019+ /* */
2020+ /* <Values> */
2021+ /* FT_OPEN_MEMORY :: This is a memory-based stream. */
2022+ /* */
2023+ /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */
2024+ /* */
2025+ /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */
2026+ /* name. */
2027+ /* */
2028+ /* FT_OPEN_DRIVER :: Use the `driver' field. */
2029+ /* */
2030+ /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */
2031+ /* */
2032+ /* <Note> */
2033+ /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */
2034+ /* flags are mutually exclusive. */
2035+ /* */
2036+#define FT_OPEN_MEMORY 0x1
2037+#define FT_OPEN_STREAM 0x2
2038+#define FT_OPEN_PATHNAME 0x4
2039+#define FT_OPEN_DRIVER 0x8
2040+#define FT_OPEN_PARAMS 0x10
2041+
2042+
2043+ /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */
2044+ /* values instead */
2045+#define ft_open_memory FT_OPEN_MEMORY
2046+#define ft_open_stream FT_OPEN_STREAM
2047+#define ft_open_pathname FT_OPEN_PATHNAME
2048+#define ft_open_driver FT_OPEN_DRIVER
2049+#define ft_open_params FT_OPEN_PARAMS
2050+
2051+
2052+ /*************************************************************************/
2053+ /* */
2054+ /* <Struct> */
2055+ /* FT_Parameter */
2056+ /* */
2057+ /* <Description> */
2058+ /* A simple structure to pass more or less generic parameters to */
2059+ /* @FT_Open_Face and @FT_Face_Properties. */
2060+ /* */
2061+ /* <Fields> */
2062+ /* tag :: A four-byte identification tag. */
2063+ /* */
2064+ /* data :: A pointer to the parameter data. */
2065+ /* */
2066+ /* <Note> */
2067+ /* The ID and function of parameters are driver-specific. See */
2068+ /* section @parameter_tags for more information. */
2069+ /* */
2070+ typedef struct FT_Parameter_
2071+ {
2072+ FT_ULong tag;
2073+ FT_Pointer data;
2074+
2075+ } FT_Parameter;
2076+
2077+
2078+ /*************************************************************************/
2079+ /* */
2080+ /* <Struct> */
2081+ /* FT_Open_Args */
2082+ /* */
2083+ /* <Description> */
2084+ /* A structure to indicate how to open a new font file or stream. A */
2085+ /* pointer to such a structure can be used as a parameter for the */
2086+ /* functions @FT_Open_Face and @FT_Attach_Stream. */
2087+ /* */
2088+ /* <Fields> */
2089+ /* flags :: A set of bit flags indicating how to use the */
2090+ /* structure. */
2091+ /* */
2092+ /* memory_base :: The first byte of the file in memory. */
2093+ /* */
2094+ /* memory_size :: The size in bytes of the file in memory. */
2095+ /* */
2096+ /* pathname :: A pointer to an 8-bit file pathname. */
2097+ /* */
2098+ /* stream :: A handle to a source stream object. */
2099+ /* */
2100+ /* driver :: This field is exclusively used by @FT_Open_Face; */
2101+ /* it simply specifies the font driver to use for */
2102+ /* opening the face. If set to NULL, FreeType tries */
2103+ /* to load the face with each one of the drivers in */
2104+ /* its list. */
2105+ /* */
2106+ /* num_params :: The number of extra parameters. */
2107+ /* */
2108+ /* params :: Extra parameters passed to the font driver when */
2109+ /* opening a new face. */
2110+ /* */
2111+ /* <Note> */
2112+ /* The stream type is determined by the contents of `flags' that */
2113+ /* are tested in the following order by @FT_Open_Face: */
2114+ /* */
2115+ /* If the @FT_OPEN_MEMORY bit is set, assume that this is a */
2116+ /* memory file of `memory_size' bytes, located at `memory_address'. */
2117+ /* The data are not copied, and the client is responsible for */
2118+ /* releasing and destroying them _after_ the corresponding call to */
2119+ /* @FT_Done_Face. */
2120+ /* */
2121+ /* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */
2122+ /* custom input stream `stream' is used. */
2123+ /* */
2124+ /* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */
2125+ /* is a normal file and use `pathname' to open it. */
2126+ /* */
2127+ /* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */
2128+ /* open the file with the driver whose handler is in `driver'. */
2129+ /* */
2130+ /* If the @FT_OPEN_PARAMS bit is set, the parameters given by */
2131+ /* `num_params' and `params' is used. They are ignored otherwise. */
2132+ /* */
2133+ /* Ideally, both the `pathname' and `params' fields should be tagged */
2134+ /* as `const'; this is missing for API backward compatibility. In */
2135+ /* other words, applications should treat them as read-only. */
2136+ /* */
2137+ typedef struct FT_Open_Args_
2138+ {
2139+ FT_UInt flags;
2140+ const FT_Byte* memory_base;
2141+ FT_Long memory_size;
2142+ FT_String* pathname;
2143+ FT_Stream stream;
2144+ FT_Module driver;
2145+ FT_Int num_params;
2146+ FT_Parameter* params;
2147+
2148+ } FT_Open_Args;
2149+
2150+
2151+ /*************************************************************************/
2152+ /* */
2153+ /* <Function> */
2154+ /* FT_New_Face */
2155+ /* */
2156+ /* <Description> */
2157+ /* Call @FT_Open_Face to open a font by its pathname. */
2158+ /* */
2159+ /* <InOut> */
2160+ /* library :: A handle to the library resource. */
2161+ /* */
2162+ /* <Input> */
2163+ /* pathname :: A path to the font file. */
2164+ /* */
2165+ /* face_index :: See @FT_Open_Face for a detailed description of this */
2166+ /* parameter. */
2167+ /* */
2168+ /* <Output> */
2169+ /* aface :: A handle to a new face object. If `face_index' is */
2170+ /* greater than or equal to zero, it must be non-NULL. */
2171+ /* */
2172+ /* <Return> */
2173+ /* FreeType error code. 0~means success. */
2174+ /* */
2175+ /* <Note> */
2176+ /* Use @FT_Done_Face to destroy the created @FT_Face object (along */
2177+ /* with its slot and sizes). */
2178+ /* */
2179+ FT_EXPORT( FT_Error )
2180+ FT_New_Face( FT_Library library,
2181+ const char* filepathname,
2182+ FT_Long face_index,
2183+ FT_Face *aface );
2184+
2185+
2186+ /*************************************************************************/
2187+ /* */
2188+ /* <Function> */
2189+ /* FT_New_Memory_Face */
2190+ /* */
2191+ /* <Description> */
2192+ /* Call @FT_Open_Face to open a font that has been loaded into */
2193+ /* memory. */
2194+ /* */
2195+ /* <InOut> */
2196+ /* library :: A handle to the library resource. */
2197+ /* */
2198+ /* <Input> */
2199+ /* file_base :: A pointer to the beginning of the font data. */
2200+ /* */
2201+ /* file_size :: The size of the memory chunk used by the font data. */
2202+ /* */
2203+ /* face_index :: See @FT_Open_Face for a detailed description of this */
2204+ /* parameter. */
2205+ /* */
2206+ /* <Output> */
2207+ /* aface :: A handle to a new face object. If `face_index' is */
2208+ /* greater than or equal to zero, it must be non-NULL. */
2209+ /* */
2210+ /* <Return> */
2211+ /* FreeType error code. 0~means success. */
2212+ /* */
2213+ /* <Note> */
2214+ /* You must not deallocate the memory before calling @FT_Done_Face. */
2215+ /* */
2216+ FT_EXPORT( FT_Error )
2217+ FT_New_Memory_Face( FT_Library library,
2218+ const FT_Byte* file_base,
2219+ FT_Long file_size,
2220+ FT_Long face_index,
2221+ FT_Face *aface );
2222+
2223+
2224+ /*************************************************************************/
2225+ /* */
2226+ /* <Function> */
2227+ /* FT_Open_Face */
2228+ /* */
2229+ /* <Description> */
2230+ /* Create a face object from a given resource described by */
2231+ /* @FT_Open_Args. */
2232+ /* */
2233+ /* <InOut> */
2234+ /* library :: A handle to the library resource. */
2235+ /* */
2236+ /* <Input> */
2237+ /* args :: A pointer to an `FT_Open_Args' structure that must */
2238+ /* be filled by the caller. */
2239+ /* */
2240+ /* face_index :: This field holds two different values. Bits 0-15 */
2241+ /* are the index of the face in the font file (starting */
2242+ /* with value~0). Set it to~0 if there is only one */
2243+ /* face in the font file. */
2244+ /* */
2245+ /* [Since 2.6.1] Bits 16-30 are relevant to GX and */
2246+ /* OpenType variation fonts only, specifying the named */
2247+ /* instance index for the current face index (starting */
2248+ /* with value~1; value~0 makes FreeType ignore named */
2249+ /* instances). For non-variation fonts, bits 16-30 are */
2250+ /* ignored. Assuming that you want to access the third */
2251+ /* named instance in face~4, `face_index' should be set */
2252+ /* to 0x00030004. If you want to access face~4 without */
2253+ /* variation handling, simply set `face_index' to */
2254+ /* value~4. */
2255+ /* */
2256+ /* `FT_Open_Face' and its siblings can be used to */
2257+ /* quickly check whether the font format of a given */
2258+ /* font resource is supported by FreeType. In general, */
2259+ /* if the `face_index' argument is negative, the */
2260+ /* function's return value is~0 if the font format is */
2261+ /* recognized, or non-zero otherwise. The function */
2262+ /* allocates a more or less empty face handle in */
2263+ /* `*aface' (if `aface' isn't NULL); the only two */
2264+ /* useful fields in this special case are */
2265+ /* `face->num_faces' and `face->style_flags'. For any */
2266+ /* negative value of `face_index', `face->num_faces' */
2267+ /* gives the number of faces within the font file. For */
2268+ /* the negative value `-(N+1)' (with `N' a non-negative */
2269+ /* 16-bit value), bits 16-30 in `face->style_flags' */
2270+ /* give the number of named instances in face `N' if we */
2271+ /* have a variation font (or zero otherwise). After */
2272+ /* examination, the returned @FT_Face structure should */
2273+ /* be deallocated with a call to @FT_Done_Face. */
2274+ /* */
2275+ /* <Output> */
2276+ /* aface :: A handle to a new face object. If `face_index' is */
2277+ /* greater than or equal to zero, it must be non-NULL. */
2278+ /* */
2279+ /* <Return> */
2280+ /* FreeType error code. 0~means success. */
2281+ /* */
2282+ /* <Note> */
2283+ /* Unlike FreeType 1.x, this function automatically creates a glyph */
2284+ /* slot for the face object that can be accessed directly through */
2285+ /* `face->glyph'. */
2286+ /* */
2287+ /* Each new face object created with this function also owns a */
2288+ /* default @FT_Size object, accessible as `face->size'. */
2289+ /* */
2290+ /* One @FT_Library instance can have multiple face objects, this is, */
2291+ /* @FT_Open_Face and its siblings can be called multiple times using */
2292+ /* the same `library' argument. */
2293+ /* */
2294+ /* See the discussion of reference counters in the description of */
2295+ /* @FT_Reference_Face. */
2296+ /* */
2297+ /* To loop over all faces, use code similar to the following snippet */
2298+ /* (omitting the error handling). */
2299+ /* */
2300+ /* { */
2301+ /* ... */
2302+ /* FT_Face face; */
2303+ /* FT_Long i, num_faces; */
2304+ /* */
2305+ /* */
2306+ /* error = FT_Open_Face( library, args, -1, &face ); */
2307+ /* if ( error ) { ... } */
2308+ /* */
2309+ /* num_faces = face->num_faces; */
2310+ /* FT_Done_Face( face ); */
2311+ /* */
2312+ /* for ( i = 0; i < num_faces; i++ ) */
2313+ /* { */
2314+ /* ... */
2315+ /* error = FT_Open_Face( library, args, i, &face ); */
2316+ /* ... */
2317+ /* FT_Done_Face( face ); */
2318+ /* ... */
2319+ /* } */
2320+ /* } */
2321+ /* */
2322+ /* To loop over all valid values for `face_index', use something */
2323+ /* similar to the following snippet, again without error handling. */
2324+ /* The code accesses all faces immediately (thus only a single call */
2325+ /* of `FT_Open_Face' within the do-loop), with and without named */
2326+ /* instances. */
2327+ /* */
2328+ /* { */
2329+ /* ... */
2330+ /* FT_Face face; */
2331+ /* */
2332+ /* FT_Long num_faces = 0; */
2333+ /* FT_Long num_instances = 0; */
2334+ /* */
2335+ /* FT_Long face_idx = 0; */
2336+ /* FT_Long instance_idx = 0; */
2337+ /* */
2338+ /* */
2339+ /* do */
2340+ /* { */
2341+ /* FT_Long id = ( instance_idx << 16 ) + face_idx; */
2342+ /* */
2343+ /* */
2344+ /* error = FT_Open_Face( library, args, id, &face ); */
2345+ /* if ( error ) { ... } */
2346+ /* */
2347+ /* num_faces = face->num_faces; */
2348+ /* num_instances = face->style_flags >> 16; */
2349+ /* */
2350+ /* ... */
2351+ /* */
2352+ /* FT_Done_Face( face ); */
2353+ /* */
2354+ /* if ( instance_idx < num_instances ) */
2355+ /* instance_idx++; */
2356+ /* else */
2357+ /* { */
2358+ /* face_idx++; */
2359+ /* instance_idx = 0; */
2360+ /* } */
2361+ /* */
2362+ /* } while ( face_idx < num_faces ) */
2363+ /* } */
2364+ /* */
2365+ FT_EXPORT( FT_Error )
2366+ FT_Open_Face( FT_Library library,
2367+ const FT_Open_Args* args,
2368+ FT_Long face_index,
2369+ FT_Face *aface );
2370+
2371+
2372+ /*************************************************************************/
2373+ /* */
2374+ /* <Function> */
2375+ /* FT_Attach_File */
2376+ /* */
2377+ /* <Description> */
2378+ /* Call @FT_Attach_Stream to attach a file. */
2379+ /* */
2380+ /* <InOut> */
2381+ /* face :: The target face object. */
2382+ /* */
2383+ /* <Input> */
2384+ /* filepathname :: The pathname. */
2385+ /* */
2386+ /* <Return> */
2387+ /* FreeType error code. 0~means success. */
2388+ /* */
2389+ FT_EXPORT( FT_Error )
2390+ FT_Attach_File( FT_Face face,
2391+ const char* filepathname );
2392+
2393+
2394+ /*************************************************************************/
2395+ /* */
2396+ /* <Function> */
2397+ /* FT_Attach_Stream */
2398+ /* */
2399+ /* <Description> */
2400+ /* `Attach' data to a face object. Normally, this is used to read */
2401+ /* additional information for the face object. For example, you can */
2402+ /* attach an AFM file that comes with a Type~1 font to get the */
2403+ /* kerning values and other metrics. */
2404+ /* */
2405+ /* <InOut> */
2406+ /* face :: The target face object. */
2407+ /* */
2408+ /* <Input> */
2409+ /* parameters :: A pointer to @FT_Open_Args that must be filled by */
2410+ /* the caller. */
2411+ /* */
2412+ /* <Return> */
2413+ /* FreeType error code. 0~means success. */
2414+ /* */
2415+ /* <Note> */
2416+ /* The meaning of the `attach' (i.e., what really happens when the */
2417+ /* new file is read) is not fixed by FreeType itself. It really */
2418+ /* depends on the font format (and thus the font driver). */
2419+ /* */
2420+ /* Client applications are expected to know what they are doing */
2421+ /* when invoking this function. Most drivers simply do not implement */
2422+ /* file or stream attachments. */
2423+ /* */
2424+ FT_EXPORT( FT_Error )
2425+ FT_Attach_Stream( FT_Face face,
2426+ FT_Open_Args* parameters );
2427+
2428+
2429+ /*************************************************************************/
2430+ /* */
2431+ /* <Function> */
2432+ /* FT_Reference_Face */
2433+ /* */
2434+ /* <Description> */
2435+ /* A counter gets initialized to~1 at the time an @FT_Face structure */
2436+ /* is created. This function increments the counter. @FT_Done_Face */
2437+ /* then only destroys a face if the counter is~1, otherwise it simply */
2438+ /* decrements the counter. */
2439+ /* */
2440+ /* This function helps in managing life-cycles of structures that */
2441+ /* reference @FT_Face objects. */
2442+ /* */
2443+ /* <Input> */
2444+ /* face :: A handle to a target face object. */
2445+ /* */
2446+ /* <Return> */
2447+ /* FreeType error code. 0~means success. */
2448+ /* */
2449+ /* <Since> */
2450+ /* 2.4.2 */
2451+ /* */
2452+ FT_EXPORT( FT_Error )
2453+ FT_Reference_Face( FT_Face face );
2454+
2455+
2456+ /*************************************************************************/
2457+ /* */
2458+ /* <Function> */
2459+ /* FT_Done_Face */
2460+ /* */
2461+ /* <Description> */
2462+ /* Discard a given face object, as well as all of its child slots and */
2463+ /* sizes. */
2464+ /* */
2465+ /* <Input> */
2466+ /* face :: A handle to a target face object. */
2467+ /* */
2468+ /* <Return> */
2469+ /* FreeType error code. 0~means success. */
2470+ /* */
2471+ /* <Note> */
2472+ /* See the discussion of reference counters in the description of */
2473+ /* @FT_Reference_Face. */
2474+ /* */
2475+ FT_EXPORT( FT_Error )
2476+ FT_Done_Face( FT_Face face );
2477+
2478+
2479+ /*************************************************************************/
2480+ /* */
2481+ /* <Function> */
2482+ /* FT_Select_Size */
2483+ /* */
2484+ /* <Description> */
2485+ /* Select a bitmap strike. To be more precise, this function sets */
2486+ /* the scaling factors of the active @FT_Size object in a face so */
2487+ /* that bitmaps from this particular strike are taken by */
2488+ /* @FT_Load_Glyph and friends. */
2489+ /* */
2490+ /* <InOut> */
2491+ /* face :: A handle to a target face object. */
2492+ /* */
2493+ /* <Input> */
2494+ /* strike_index :: The index of the bitmap strike in the */
2495+ /* `available_sizes' field of @FT_FaceRec structure. */
2496+ /* */
2497+ /* <Return> */
2498+ /* FreeType error code. 0~means success. */
2499+ /* */
2500+ /* <Note> */
2501+ /* For bitmaps embedded in outline fonts it is common that only a */
2502+ /* subset of the available glyphs at a given ppem value is available. */
2503+ /* FreeType silently uses outlines if there is no bitmap for a given */
2504+ /* glyph index. */
2505+ /* */
2506+ /* For GX and OpenType variation fonts, a bitmap strike makes sense */
2507+ /* only if the default instance is active (this is, no glyph */
2508+ /* variation takes place); otherwise, FreeType simply ignores bitmap */
2509+ /* strikes. The same is true for all named instances that are */
2510+ /* different from the default instance. */
2511+ /* */
2512+ /* Don't use this function if you are using the FreeType cache API. */
2513+ /* */
2514+ FT_EXPORT( FT_Error )
2515+ FT_Select_Size( FT_Face face,
2516+ FT_Int strike_index );
2517+
2518+
2519+ /*************************************************************************/
2520+ /* */
2521+ /* <Enum> */
2522+ /* FT_Size_Request_Type */
2523+ /* */
2524+ /* <Description> */
2525+ /* An enumeration type that lists the supported size request types, */
2526+ /* i.e., what input size (in font units) maps to the requested output */
2527+ /* size (in pixels, as computed from the arguments of */
2528+ /* @FT_Size_Request). */
2529+ /* */
2530+ /* <Values> */
2531+ /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */
2532+ /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */
2533+ /* used to determine both scaling values. */
2534+ /* */
2535+ /* This is the standard scaling found in most applications. In */
2536+ /* particular, use this size request type for TrueType fonts if */
2537+ /* they provide optical scaling or something similar. Note, */
2538+ /* however, that `units_per_EM' is a rather abstract value which */
2539+ /* bears no relation to the actual size of the glyphs in a font. */
2540+ /* */
2541+ /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */
2542+ /* The real dimension. The sum of the `ascender' and (minus of) */
2543+ /* the `descender' fields of @FT_FaceRec is used to determine both */
2544+ /* scaling values. */
2545+ /* */
2546+ /* FT_SIZE_REQUEST_TYPE_BBOX :: */
2547+ /* The font bounding box. The width and height of the `bbox' field */
2548+ /* of @FT_FaceRec are used to determine the horizontal and vertical */
2549+ /* scaling value, respectively. */
2550+ /* */
2551+ /* FT_SIZE_REQUEST_TYPE_CELL :: */
2552+ /* The `max_advance_width' field of @FT_FaceRec is used to */
2553+ /* determine the horizontal scaling value; the vertical scaling */
2554+ /* value is determined the same way as */
2555+ /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */
2556+ /* values are set to the smaller one. This type is useful if you */
2557+ /* want to specify the font size for, say, a window of a given */
2558+ /* dimension and 80x24 cells. */
2559+ /* */
2560+ /* FT_SIZE_REQUEST_TYPE_SCALES :: */
2561+ /* Specify the scaling values directly. */
2562+ /* */
2563+ /* <Note> */
2564+ /* The above descriptions only apply to scalable formats. For bitmap */
2565+ /* formats, the behaviour is up to the driver. */
2566+ /* */
2567+ /* See the note section of @FT_Size_Metrics if you wonder how size */
2568+ /* requesting relates to scaling values. */
2569+ /* */
2570+ typedef enum FT_Size_Request_Type_
2571+ {
2572+ FT_SIZE_REQUEST_TYPE_NOMINAL,
2573+ FT_SIZE_REQUEST_TYPE_REAL_DIM,
2574+ FT_SIZE_REQUEST_TYPE_BBOX,
2575+ FT_SIZE_REQUEST_TYPE_CELL,
2576+ FT_SIZE_REQUEST_TYPE_SCALES,
2577+
2578+ FT_SIZE_REQUEST_TYPE_MAX
2579+
2580+ } FT_Size_Request_Type;
2581+
2582+
2583+ /*************************************************************************/
2584+ /* */
2585+ /* <Struct> */
2586+ /* FT_Size_RequestRec */
2587+ /* */
2588+ /* <Description> */
2589+ /* A structure to model a size request. */
2590+ /* */
2591+ /* <Fields> */
2592+ /* type :: See @FT_Size_Request_Type. */
2593+ /* */
2594+ /* width :: The desired width, given as a 26.6 fractional */
2595+ /* point value (with 72pt = 1in). */
2596+ /* */
2597+ /* height :: The desired height, given as a 26.6 fractional */
2598+ /* point value (with 72pt = 1in). */
2599+ /* */
2600+ /* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */
2601+ /* inch). If set to zero, `width' is treated as a */
2602+ /* 26.6 fractional *pixel* value, which gets */
2603+ /* internally rounded to an integer. */
2604+ /* */
2605+ /* vertResolution :: The vertical resolution (dpi, i.e., pixels per */
2606+ /* inch). If set to zero, `height' is treated as a */
2607+ /* 26.6 fractional *pixel* value, which gets */
2608+ /* internally rounded to an integer. */
2609+ /* */
2610+ /* <Note> */
2611+ /* If `width' is zero, the horizontal scaling value is set equal */
2612+ /* to the vertical scaling value, and vice versa. */
2613+ /* */
2614+ /* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */
2615+ /* interpreted directly as 16.16 fractional scaling values, without */
2616+ /* any further modification, and both `horiResolution' and */
2617+ /* `vertResolution' are ignored. */
2618+ /* */
2619+ typedef struct FT_Size_RequestRec_
2620+ {
2621+ FT_Size_Request_Type type;
2622+ FT_Long width;
2623+ FT_Long height;
2624+ FT_UInt horiResolution;
2625+ FT_UInt vertResolution;
2626+
2627+ } FT_Size_RequestRec;
2628+
2629+
2630+ /*************************************************************************/
2631+ /* */
2632+ /* <Struct> */
2633+ /* FT_Size_Request */
2634+ /* */
2635+ /* <Description> */
2636+ /* A handle to a size request structure. */
2637+ /* */
2638+ typedef struct FT_Size_RequestRec_ *FT_Size_Request;
2639+
2640+
2641+ /*************************************************************************/
2642+ /* */
2643+ /* <Function> */
2644+ /* FT_Request_Size */
2645+ /* */
2646+ /* <Description> */
2647+ /* Resize the scale of the active @FT_Size object in a face. */
2648+ /* */
2649+ /* <InOut> */
2650+ /* face :: A handle to a target face object. */
2651+ /* */
2652+ /* <Input> */
2653+ /* req :: A pointer to a @FT_Size_RequestRec. */
2654+ /* */
2655+ /* <Return> */
2656+ /* FreeType error code. 0~means success. */
2657+ /* */
2658+ /* <Note> */
2659+ /* Although drivers may select the bitmap strike matching the */
2660+ /* request, you should not rely on this if you intend to select a */
2661+ /* particular bitmap strike. Use @FT_Select_Size instead in that */
2662+ /* case. */
2663+ /* */
2664+ /* The relation between the requested size and the resulting glyph */
2665+ /* size is dependent entirely on how the size is defined in the */
2666+ /* source face. The font designer chooses the final size of each */
2667+ /* glyph relative to this size. For more information refer to */
2668+ /* `https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. */
2669+ /* */
2670+ /* Contrary to @FT_Set_Char_Size, this function doesn't have special */
2671+ /* code to normalize zero-valued widths, heights, or resolutions */
2672+ /* (which lead to errors in most cases). */
2673+ /* */
2674+ /* Don't use this function if you are using the FreeType cache API. */
2675+ /* */
2676+ FT_EXPORT( FT_Error )
2677+ FT_Request_Size( FT_Face face,
2678+ FT_Size_Request req );
2679+
2680+
2681+ /*************************************************************************/
2682+ /* */
2683+ /* <Function> */
2684+ /* FT_Set_Char_Size */
2685+ /* */
2686+ /* <Description> */
2687+ /* Call @FT_Request_Size to request the nominal size (in points). */
2688+ /* */
2689+ /* <InOut> */
2690+ /* face :: A handle to a target face object. */
2691+ /* */
2692+ /* <Input> */
2693+ /* char_width :: The nominal width, in 26.6 fractional points. */
2694+ /* */
2695+ /* char_height :: The nominal height, in 26.6 fractional points. */
2696+ /* */
2697+ /* horz_resolution :: The horizontal resolution in dpi. */
2698+ /* */
2699+ /* vert_resolution :: The vertical resolution in dpi. */
2700+ /* */
2701+ /* <Return> */
2702+ /* FreeType error code. 0~means success. */
2703+ /* */
2704+ /* <Note> */
2705+ /* While this function allows fractional points as input values, the */
2706+ /* resulting ppem value for the given resolution is always rounded to */
2707+ /* the nearest integer. */
2708+ /* */
2709+ /* If either the character width or height is zero, it is set equal */
2710+ /* to the other value. */
2711+ /* */
2712+ /* If either the horizontal or vertical resolution is zero, it is set */
2713+ /* equal to the other value. */
2714+ /* */
2715+ /* A character width or height smaller than 1pt is set to 1pt; if */
2716+ /* both resolution values are zero, they are set to 72dpi. */
2717+ /* */
2718+ /* Don't use this function if you are using the FreeType cache API. */
2719+ /* */
2720+ FT_EXPORT( FT_Error )
2721+ FT_Set_Char_Size( FT_Face face,
2722+ FT_F26Dot6 char_width,
2723+ FT_F26Dot6 char_height,
2724+ FT_UInt horz_resolution,
2725+ FT_UInt vert_resolution );
2726+
2727+
2728+ /*************************************************************************/
2729+ /* */
2730+ /* <Function> */
2731+ /* FT_Set_Pixel_Sizes */
2732+ /* */
2733+ /* <Description> */
2734+ /* Call @FT_Request_Size to request the nominal size (in pixels). */
2735+ /* */
2736+ /* <InOut> */
2737+ /* face :: A handle to the target face object. */
2738+ /* */
2739+ /* <Input> */
2740+ /* pixel_width :: The nominal width, in pixels. */
2741+ /* */
2742+ /* pixel_height :: The nominal height, in pixels. */
2743+ /* */
2744+ /* <Return> */
2745+ /* FreeType error code. 0~means success. */
2746+ /* */
2747+ /* <Note> */
2748+ /* You should not rely on the resulting glyphs matching or being */
2749+ /* constrained to this pixel size. Refer to @FT_Request_Size to */
2750+ /* understand how requested sizes relate to actual sizes. */
2751+ /* */
2752+ /* Don't use this function if you are using the FreeType cache API. */
2753+ /* */
2754+ FT_EXPORT( FT_Error )
2755+ FT_Set_Pixel_Sizes( FT_Face face,
2756+ FT_UInt pixel_width,
2757+ FT_UInt pixel_height );
2758+
2759+
2760+ /*************************************************************************/
2761+ /* */
2762+ /* <Function> */
2763+ /* FT_Load_Glyph */
2764+ /* */
2765+ /* <Description> */
2766+ /* Load a glyph into the glyph slot of a face object. */
2767+ /* */
2768+ /* <InOut> */
2769+ /* face :: A handle to the target face object where the glyph */
2770+ /* is loaded. */
2771+ /* */
2772+ /* <Input> */
2773+ /* glyph_index :: The index of the glyph in the font file. For */
2774+ /* CID-keyed fonts (either in PS or in CFF format) */
2775+ /* this argument specifies the CID value. */
2776+ /* */
2777+ /* load_flags :: A flag indicating what to load for this glyph. The */
2778+ /* @FT_LOAD_XXX constants can be used to control the */
2779+ /* glyph loading process (e.g., whether the outline */
2780+ /* should be scaled, whether to load bitmaps or not, */
2781+ /* whether to hint the outline, etc). */
2782+ /* */
2783+ /* <Return> */
2784+ /* FreeType error code. 0~means success. */
2785+ /* */
2786+ /* <Note> */
2787+ /* The loaded glyph may be transformed. See @FT_Set_Transform for */
2788+ /* the details. */
2789+ /* */
2790+ /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */
2791+ /* returned for invalid CID values (this is, for CID values that */
2792+ /* don't have a corresponding glyph in the font). See the discussion */
2793+ /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */
2794+ /* */
2795+ /* If you receive `FT_Err_Glyph_Too_Big', try getting the glyph */
2796+ /* outline at EM size, then scale it manually and fill it as a */
2797+ /* graphics operation. */
2798+ /* */
2799+ FT_EXPORT( FT_Error )
2800+ FT_Load_Glyph( FT_Face face,
2801+ FT_UInt glyph_index,
2802+ FT_Int32 load_flags );
2803+
2804+
2805+ /*************************************************************************/
2806+ /* */
2807+ /* <Function> */
2808+ /* FT_Load_Char */
2809+ /* */
2810+ /* <Description> */
2811+ /* Load a glyph into the glyph slot of a face object, accessed by its */
2812+ /* character code. */
2813+ /* */
2814+ /* <InOut> */
2815+ /* face :: A handle to a target face object where the glyph */
2816+ /* is loaded. */
2817+ /* */
2818+ /* <Input> */
2819+ /* char_code :: The glyph's character code, according to the */
2820+ /* current charmap used in the face. */
2821+ /* */
2822+ /* load_flags :: A flag indicating what to load for this glyph. The */
2823+ /* @FT_LOAD_XXX constants can be used to control the */
2824+ /* glyph loading process (e.g., whether the outline */
2825+ /* should be scaled, whether to load bitmaps or not, */
2826+ /* whether to hint the outline, etc). */
2827+ /* */
2828+ /* <Return> */
2829+ /* FreeType error code. 0~means success. */
2830+ /* */
2831+ /* <Note> */
2832+ /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */
2833+ /* */
2834+ /* Many fonts contain glyphs that can't be loaded by this function */
2835+ /* since its glyph indices are not listed in any of the font's */
2836+ /* charmaps. */
2837+ /* */
2838+ /* If no active cmap is set up (i.e., `face->charmap' is zero), the */
2839+ /* call to @FT_Get_Char_Index is omitted, and the function behaves */
2840+ /* identically to @FT_Load_Glyph. */
2841+ /* */
2842+ FT_EXPORT( FT_Error )
2843+ FT_Load_Char( FT_Face face,
2844+ FT_ULong char_code,
2845+ FT_Int32 load_flags );
2846+
2847+
2848+ /*************************************************************************
2849+ *
2850+ * @enum:
2851+ * FT_LOAD_XXX
2852+ *
2853+ * @description:
2854+ * A list of bit field constants for @FT_Load_Glyph to indicate what
2855+ * kind of operations to perform during glyph loading.
2856+ *
2857+ * @values:
2858+ * FT_LOAD_DEFAULT ::
2859+ * Corresponding to~0, this value is used as the default glyph load
2860+ * operation. In this case, the following happens:
2861+ *
2862+ * 1. FreeType looks for a bitmap for the glyph corresponding to the
2863+ * face's current size. If one is found, the function returns.
2864+ * The bitmap data can be accessed from the glyph slot (see note
2865+ * below).
2866+ *
2867+ * 2. If no embedded bitmap is searched for or found, FreeType looks
2868+ * for a scalable outline. If one is found, it is loaded from
2869+ * the font file, scaled to device pixels, then `hinted' to the
2870+ * pixel grid in order to optimize it. The outline data can be
2871+ * accessed from the glyph slot (see note below).
2872+ *
2873+ * Note that by default the glyph loader doesn't render outlines into
2874+ * bitmaps. The following flags are used to modify this default
2875+ * behaviour to more specific and useful cases.
2876+ *
2877+ * FT_LOAD_NO_SCALE ::
2878+ * Don't scale the loaded outline glyph but keep it in font units.
2879+ *
2880+ * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
2881+ * unsets @FT_LOAD_RENDER.
2882+ *
2883+ * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using
2884+ * FT_LOAD_NO_SCALE usually yields meaningless outlines because the
2885+ * subglyphs must be scaled and positioned with hinting instructions.
2886+ * This can be solved by loading the font without FT_LOAD_NO_SCALE and
2887+ * setting the character size to `font->units_per_EM'.
2888+ *
2889+ * FT_LOAD_NO_HINTING ::
2890+ * Disable hinting. This generally generates `blurrier' bitmap glyphs
2891+ * when the glyph are rendered in any of the anti-aliased modes. See
2892+ * also the note below.
2893+ *
2894+ * This flag is implied by @FT_LOAD_NO_SCALE.
2895+ *
2896+ * FT_LOAD_RENDER ::
2897+ * Call @FT_Render_Glyph after the glyph is loaded. By default, the
2898+ * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
2899+ * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
2900+ *
2901+ * This flag is unset by @FT_LOAD_NO_SCALE.
2902+ *
2903+ * FT_LOAD_NO_BITMAP ::
2904+ * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
2905+ * flag.
2906+ *
2907+ * @FT_LOAD_NO_SCALE always sets this flag.
2908+ *
2909+ * FT_LOAD_VERTICAL_LAYOUT ::
2910+ * Load the glyph for vertical text layout. In particular, the
2911+ * `advance' value in the @FT_GlyphSlotRec structure is set to the
2912+ * `vertAdvance' value of the `metrics' field.
2913+ *
2914+ * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use
2915+ * this flag currently. Reason is that in this case vertical metrics
2916+ * get synthesized, and those values are not always consistent across
2917+ * various font formats.
2918+ *
2919+ * FT_LOAD_FORCE_AUTOHINT ::
2920+ * Prefer the auto-hinter over the font's native hinter. See also
2921+ * the note below.
2922+ *
2923+ * FT_LOAD_PEDANTIC ::
2924+ * Make the font driver perform pedantic verifications during glyph
2925+ * loading. This is mostly used to detect broken glyphs in fonts.
2926+ * By default, FreeType tries to handle broken fonts also.
2927+ *
2928+ * In particular, errors from the TrueType bytecode engine are not
2929+ * passed to the application if this flag is not set; this might
2930+ * result in partially hinted or distorted glyphs in case a glyph's
2931+ * bytecode is buggy.
2932+ *
2933+ * FT_LOAD_NO_RECURSE ::
2934+ * Don't load composite glyphs recursively. Instead, the font
2935+ * driver should set the `num_subglyph' and `subglyphs' values of
2936+ * the glyph slot accordingly, and set `glyph->format' to
2937+ * @FT_GLYPH_FORMAT_COMPOSITE. The description of subglyphs can
2938+ * then be accessed with @FT_Get_SubGlyph_Info.
2939+ *
2940+ * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
2941+ *
2942+ * FT_LOAD_IGNORE_TRANSFORM ::
2943+ * Ignore the transform matrix set by @FT_Set_Transform.
2944+ *
2945+ * FT_LOAD_MONOCHROME ::
2946+ * This flag is used with @FT_LOAD_RENDER to indicate that you want to
2947+ * render an outline glyph to a 1-bit monochrome bitmap glyph, with
2948+ * 8~pixels packed into each byte of the bitmap data.
2949+ *
2950+ * Note that this has no effect on the hinting algorithm used. You
2951+ * should rather use @FT_LOAD_TARGET_MONO so that the
2952+ * monochrome-optimized hinting algorithm is used.
2953+ *
2954+ * FT_LOAD_LINEAR_DESIGN ::
2955+ * Keep `linearHoriAdvance' and `linearVertAdvance' fields of
2956+ * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for
2957+ * details.
2958+ *
2959+ * FT_LOAD_NO_AUTOHINT ::
2960+ * Disable the auto-hinter. See also the note below.
2961+ *
2962+ * FT_LOAD_COLOR ::
2963+ * [Since 2.5] Load embedded color bitmap images. The resulting color
2964+ * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format.
2965+ * If the flag is not set and color bitmaps are found, they are
2966+ * converted to 256-level gray bitmaps transparently, using the
2967+ * @FT_PIXEL_MODE_GRAY format.
2968+ *
2969+ * FT_LOAD_COMPUTE_METRICS ::
2970+ * [Since 2.6.1] Compute glyph metrics from the glyph data, without
2971+ * the use of bundled metrics tables (for example, the `hdmx' table in
2972+ * TrueType fonts). This flag is mainly used by font validating or
2973+ * font editing applications, which need to ignore, verify, or edit
2974+ * those tables.
2975+ *
2976+ * Currently, this flag is only implemented for TrueType fonts.
2977+ *
2978+ * FT_LOAD_BITMAP_METRICS_ONLY ::
2979+ * [Since 2.7.1] Request loading of the metrics and bitmap image
2980+ * information of a (possibly embedded) bitmap glyph without
2981+ * allocating or copying the bitmap image data itself. No effect if
2982+ * the target glyph is not a bitmap image.
2983+ *
2984+ * This flag unsets @FT_LOAD_RENDER.
2985+ *
2986+ * FT_LOAD_CROP_BITMAP ::
2987+ * Ignored. Deprecated.
2988+ *
2989+ * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
2990+ * Ignored. Deprecated.
2991+ *
2992+ * @note:
2993+ * By default, hinting is enabled and the font's native hinter (see
2994+ * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
2995+ * disable hinting by setting @FT_LOAD_NO_HINTING or change the
2996+ * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
2997+ * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be
2998+ * used at all.
2999+ *
3000+ * See the description of @FT_FACE_FLAG_TRICKY for a special exception
3001+ * (affecting only a handful of Asian fonts).
3002+ *
3003+ * Besides deciding which hinter to use, you can also decide which
3004+ * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
3005+ *
3006+ * Note that the auto-hinter needs a valid Unicode cmap (either a native
3007+ * one or synthesized by FreeType) for producing correct results. If a
3008+ * font provides an incorrect mapping (for example, assigning the
3009+ * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a
3010+ * mathematical integral sign), the auto-hinter might produce useless
3011+ * results.
3012+ *
3013+ */
3014+#define FT_LOAD_DEFAULT 0x0
3015+#define FT_LOAD_NO_SCALE ( 1L << 0 )
3016+#define FT_LOAD_NO_HINTING ( 1L << 1 )
3017+#define FT_LOAD_RENDER ( 1L << 2 )
3018+#define FT_LOAD_NO_BITMAP ( 1L << 3 )
3019+#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
3020+#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
3021+#define FT_LOAD_CROP_BITMAP ( 1L << 6 )
3022+#define FT_LOAD_PEDANTIC ( 1L << 7 )
3023+#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
3024+#define FT_LOAD_NO_RECURSE ( 1L << 10 )
3025+#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
3026+#define FT_LOAD_MONOCHROME ( 1L << 12 )
3027+#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
3028+#define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
3029+ /* Bits 16-19 are used by `FT_LOAD_TARGET_' */
3030+#define FT_LOAD_COLOR ( 1L << 20 )
3031+#define FT_LOAD_COMPUTE_METRICS ( 1L << 21 )
3032+#define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 )
3033+
3034+ /* */
3035+
3036+ /* used internally only by certain font drivers */
3037+#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
3038+#define FT_LOAD_SBITS_ONLY ( 1L << 14 )
3039+
3040+
3041+ /**************************************************************************
3042+ *
3043+ * @enum:
3044+ * FT_LOAD_TARGET_XXX
3045+ *
3046+ * @description:
3047+ * A list of values to select a specific hinting algorithm for the
3048+ * hinter. You should OR one of these values to your `load_flags'
3049+ * when calling @FT_Load_Glyph.
3050+ *
3051+ * Note that a font's native hinters may ignore the hinting algorithm
3052+ * you have specified (e.g., the TrueType bytecode interpreter). You
3053+ * can set @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is
3054+ * used.
3055+ *
3056+ * @values:
3057+ * FT_LOAD_TARGET_NORMAL ::
3058+ * The default hinting algorithm, optimized for standard gray-level
3059+ * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO
3060+ * instead.
3061+ *
3062+ * FT_LOAD_TARGET_LIGHT ::
3063+ * A lighter hinting algorithm for gray-level modes. Many generated
3064+ * glyphs are fuzzier but better resemble their original shape. This
3065+ * is achieved by snapping glyphs to the pixel grid only vertically
3066+ * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's
3067+ * ClearType font renderer. This preserves inter-glyph spacing in
3068+ * horizontal text. The snapping is done either by the native font
3069+ * driver, if the driver itself and the font support it, or by the
3070+ * auto-hinter.
3071+ *
3072+ * Advance widths are rounded to integer values; however, using the
3073+ * `lsb_delta' and `rsb_delta' fields of @FT_GlyphSlotRec, it is
3074+ * possible to get fractional advance widths for subpixel positioning
3075+ * (which is recommended to use).
3076+ *
3077+ * If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active,
3078+ * TrueType-like metrics are used to make this mode behave similarly
3079+ * as in unpatched FreeType versions between 2.4.6 and 2.7.1
3080+ * (inclusive).
3081+ *
3082+ * FT_LOAD_TARGET_MONO ::
3083+ * Strong hinting algorithm that should only be used for monochrome
3084+ * output. The result is probably unpleasant if the glyph is rendered
3085+ * in non-monochrome modes.
3086+ *
3087+ * FT_LOAD_TARGET_LCD ::
3088+ * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally
3089+ * decimated LCD displays.
3090+ *
3091+ * FT_LOAD_TARGET_LCD_V ::
3092+ * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
3093+ * decimated LCD displays.
3094+ *
3095+ * @note:
3096+ * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your
3097+ * `load_flags'. They can't be ORed.
3098+ *
3099+ * If @FT_LOAD_RENDER is also set, the glyph is rendered in the
3100+ * corresponding mode (i.e., the mode that matches the used algorithm
3101+ * best). An exception is FT_LOAD_TARGET_MONO since it implies
3102+ * @FT_LOAD_MONOCHROME.
3103+ *
3104+ * You can use a hinting algorithm that doesn't correspond to the same
3105+ * rendering mode. As an example, it is possible to use the `light'
3106+ * hinting algorithm and have the results rendered in horizontal LCD
3107+ * pixel mode, with code like
3108+ *
3109+ * {
3110+ * FT_Load_Glyph( face, glyph_index,
3111+ * load_flags | FT_LOAD_TARGET_LIGHT );
3112+ *
3113+ * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
3114+ * }
3115+ *
3116+ * In general, you should stick with one rendering mode. For example,
3117+ * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO
3118+ * enforces a lot of recomputation for TrueType fonts, which is slow.
3119+ * Another reason is caching: Selecting a different mode usually causes
3120+ * changes in both the outlines and the rasterized bitmaps; it is thus
3121+ * necessary to empty the cache after a mode switch to avoid false hits.
3122+ *
3123+ */
3124+#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
3125+
3126+#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
3127+#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
3128+#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
3129+#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
3130+#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
3131+
3132+
3133+ /**************************************************************************
3134+ *
3135+ * @macro:
3136+ * FT_LOAD_TARGET_MODE
3137+ *
3138+ * @description:
3139+ * Return the @FT_Render_Mode corresponding to a given
3140+ * @FT_LOAD_TARGET_XXX value.
3141+ *
3142+ */
3143+#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
3144+
3145+
3146+ /*************************************************************************/
3147+ /* */
3148+ /* <Function> */
3149+ /* FT_Set_Transform */
3150+ /* */
3151+ /* <Description> */
3152+ /* Set the transformation that is applied to glyph images when they */
3153+ /* are loaded into a glyph slot through @FT_Load_Glyph. */
3154+ /* */
3155+ /* <InOut> */
3156+ /* face :: A handle to the source face object. */
3157+ /* */
3158+ /* <Input> */
3159+ /* matrix :: A pointer to the transformation's 2x2 matrix. Use NULL */
3160+ /* for the identity matrix. */
3161+ /* delta :: A pointer to the translation vector. Use NULL for the */
3162+ /* null vector. */
3163+ /* */
3164+ /* <Note> */
3165+ /* The transformation is only applied to scalable image formats after */
3166+ /* the glyph has been loaded. It means that hinting is unaltered by */
3167+ /* the transformation and is performed on the character size given in */
3168+ /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */
3169+ /* */
3170+ /* Note that this also transforms the `face.glyph.advance' field, but */
3171+ /* *not* the values in `face.glyph.metrics'. */
3172+ /* */
3173+ FT_EXPORT( void )
3174+ FT_Set_Transform( FT_Face face,
3175+ FT_Matrix* matrix,
3176+ FT_Vector* delta );
3177+
3178+
3179+ /*************************************************************************/
3180+ /* */
3181+ /* <Enum> */
3182+ /* FT_Render_Mode */
3183+ /* */
3184+ /* <Description> */
3185+ /* Render modes supported by FreeType~2. Each mode corresponds to a */
3186+ /* specific type of scanline conversion performed on the outline. */
3187+ /* */
3188+ /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */
3189+ /* field in the @FT_GlyphSlotRec structure gives the format of the */
3190+ /* returned bitmap. */
3191+ /* */
3192+ /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */
3193+ /* indicating pixel coverage. Use linear alpha blending and gamma */
3194+ /* correction to correctly render non-monochrome glyph bitmaps onto a */
3195+ /* surface; see @FT_Render_Glyph. */
3196+ /* */
3197+ /* <Values> */
3198+ /* FT_RENDER_MODE_NORMAL :: */
3199+ /* Default render mode; it corresponds to 8-bit anti-aliased */
3200+ /* bitmaps. */
3201+ /* */
3202+ /* FT_RENDER_MODE_LIGHT :: */
3203+ /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */
3204+ /* defined as a separate value because render modes are also used */
3205+ /* indirectly to define hinting algorithm selectors. See */
3206+ /* @FT_LOAD_TARGET_XXX for details. */
3207+ /* */
3208+ /* FT_RENDER_MODE_MONO :: */
3209+ /* This mode corresponds to 1-bit bitmaps (with 2~levels of */
3210+ /* opacity). */
3211+ /* */
3212+ /* FT_RENDER_MODE_LCD :: */
3213+ /* This mode corresponds to horizontal RGB and BGR subpixel */
3214+ /* displays like LCD screens. It produces 8-bit bitmaps that are */
3215+ /* 3~times the width of the original glyph outline in pixels, and */
3216+ /* which use the @FT_PIXEL_MODE_LCD mode. */
3217+ /* */
3218+ /* FT_RENDER_MODE_LCD_V :: */
3219+ /* This mode corresponds to vertical RGB and BGR subpixel displays */
3220+ /* (like PDA screens, rotated LCD displays, etc.). It produces */
3221+ /* 8-bit bitmaps that are 3~times the height of the original */
3222+ /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */
3223+ /* */
3224+ /* <Note> */
3225+ /* Should you define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your */
3226+ /* `ftoption.h', which enables patented ClearType-style rendering, */
3227+ /* the LCD-optimized glyph bitmaps should be filtered to reduce color */
3228+ /* fringes inherent to this technology. You can either set up LCD */
3229+ /* filtering with @FT_Library_SetLcdFilter or @FT_Face_Properties, */
3230+ /* or do the filtering yourself. The default FreeType LCD rendering */
3231+ /* technology does not require filtering. */
3232+ /* */
3233+ /* The selected render mode only affects vector glyphs of a font. */
3234+ /* Embedded bitmaps often have a different pixel mode like */
3235+ /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */
3236+ /* them into 8-bit pixmaps. */
3237+ /* */
3238+ typedef enum FT_Render_Mode_
3239+ {
3240+ FT_RENDER_MODE_NORMAL = 0,
3241+ FT_RENDER_MODE_LIGHT,
3242+ FT_RENDER_MODE_MONO,
3243+ FT_RENDER_MODE_LCD,
3244+ FT_RENDER_MODE_LCD_V,
3245+
3246+ FT_RENDER_MODE_MAX
3247+
3248+ } FT_Render_Mode;
3249+
3250+
3251+ /* these constants are deprecated; use the corresponding */
3252+ /* `FT_Render_Mode' values instead */
3253+#define ft_render_mode_normal FT_RENDER_MODE_NORMAL
3254+#define ft_render_mode_mono FT_RENDER_MODE_MONO
3255+
3256+
3257+ /*************************************************************************/
3258+ /* */
3259+ /* <Function> */
3260+ /* FT_Render_Glyph */
3261+ /* */
3262+ /* <Description> */
3263+ /* Convert a given glyph image to a bitmap. It does so by inspecting */
3264+ /* the glyph image format, finding the relevant renderer, and */
3265+ /* invoking it. */
3266+ /* */
3267+ /* <InOut> */
3268+ /* slot :: A handle to the glyph slot containing the image to */
3269+ /* convert. */
3270+ /* */
3271+ /* <Input> */
3272+ /* render_mode :: The render mode used to render the glyph image into */
3273+ /* a bitmap. See @FT_Render_Mode for a list of */
3274+ /* possible values. */
3275+ /* */
3276+ /* <Return> */
3277+ /* FreeType error code. 0~means success. */
3278+ /* */
3279+ /* <Note> */
3280+ /* To get meaningful results, font scaling values must be set with */
3281+ /* functions like @FT_Set_Char_Size before calling `FT_Render_Glyph'. */
3282+ /* */
3283+ /* When FreeType outputs a bitmap of a glyph, it really outputs an */
3284+ /* alpha coverage map. If a pixel is completely covered by a */
3285+ /* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */
3286+ /* that 0xFF/0xFF fraction of that pixel is covered, meaning the */
3287+ /* pixel is 100% black (or 0% bright). If a pixel is only 50% */
3288+ /* covered (value 0x80), the pixel is made 50% black (50% bright or a */
3289+ /* middle shade of grey). 0% covered means 0% black (100% bright or */
3290+ /* white). */
3291+ /* */
3292+ /* On high-DPI screens like on smartphones and tablets, the pixels */
3293+ /* are so small that their chance of being completely covered and */
3294+ /* therefore completely black are fairly good. On the low-DPI */
3295+ /* screens, however, the situation is different. The pixels are too */
3296+ /* large for most of the details of a glyph and shades of gray are */
3297+ /* the norm rather than the exception. */
3298+ /* */
3299+ /* This is relevant because all our screens have a second problem: */
3300+ /* they are not linear. 1~+~1 is not~2. Twice the value does not */
3301+ /* result in twice the brightness. When a pixel is only 50% covered, */
3302+ /* the coverage map says 50% black, and this translates to a pixel */
3303+ /* value of 128 when you use 8~bits per channel (0-255). However, */
3304+ /* this does not translate to 50% brightness for that pixel on our */
3305+ /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */
3306+ /* dwell longer in the darks and only a pixel value of about 186 */
3307+ /* results in 50% brightness -- 128 ends up too dark on both bright */
3308+ /* and dark backgrounds. The net result is that dark text looks */
3309+ /* burnt-out, pixely and blotchy on bright background, bright text */
3310+ /* too frail on dark backgrounds, and colored text on colored */
3311+ /* background (for example, red on green) seems to have dark halos or */
3312+ /* `dirt' around it. The situation is especially ugly for diagonal */
3313+ /* stems like in `w' glyph shapes where the quality of FreeType's */
3314+ /* anti-aliasing depends on the correct display of grays. On */
3315+ /* high-DPI screens where smaller, fully black pixels reign supreme, */
3316+ /* this doesn't matter, but on our low-DPI screens with all the gray */
3317+ /* shades, it does. 0% and 100% brightness are the same things in */
3318+ /* linear and non-linear space, just all the shades in-between */
3319+ /* aren't. */
3320+ /* */
3321+ /* The blending function for placing text over a background is */
3322+ /* */
3323+ /* { */
3324+ /* dst = alpha * src + (1 - alpha) * dst , */
3325+ /* } */
3326+ /* */
3327+ /* which is known as the OVER operator. */
3328+ /* */
3329+ /* To correctly composite an antialiased pixel of a glyph onto a */
3330+ /* surface, */
3331+ /* */
3332+ /* 1. take the foreground and background colors (e.g., in sRGB space) */
3333+ /* and apply gamma to get them in a linear space, */
3334+ /* */
3335+ /* 2. use OVER to blend the two linear colors using the glyph pixel */
3336+ /* as the alpha value (remember, the glyph bitmap is an alpha */
3337+ /* coverage bitmap), and */
3338+ /* */
3339+ /* 3. apply inverse gamma to the blended pixel and write it back to */
3340+ /* the image. */
3341+ /* */
3342+ /* Internal testing at Adobe found that a target inverse gamma of~1.8 */
3343+ /* for step~3 gives good results across a wide range of displays with */
3344+ /* an sRGB gamma curve or a similar one. */
3345+ /* */
3346+ /* This process can cost performance. There is an approximation that */
3347+ /* does not need to know about the background color; see */
3348+ /* https://bel.fi/alankila/lcd/ and */
3349+ /* https://bel.fi/alankila/lcd/alpcor.html for details. */
3350+ /* */
3351+ /* *ATTENTION*: Linear blending is even more important when dealing */
3352+ /* with subpixel-rendered glyphs to prevent color-fringing! A */
3353+ /* subpixel-rendered glyph must first be filtered with a filter that */
3354+ /* gives equal weight to the three color primaries and does not */
3355+ /* exceed a sum of 0x100, see section @lcd_filtering. Then the */
3356+ /* only difference to gray linear blending is that subpixel-rendered */
3357+ /* linear blending is done 3~times per pixel: red foreground subpixel */
3358+ /* to red background subpixel and so on for green and blue. */
3359+ /* */
3360+ FT_EXPORT( FT_Error )
3361+ FT_Render_Glyph( FT_GlyphSlot slot,
3362+ FT_Render_Mode render_mode );
3363+
3364+
3365+ /*************************************************************************/
3366+ /* */
3367+ /* <Enum> */
3368+ /* FT_Kerning_Mode */
3369+ /* */
3370+ /* <Description> */
3371+ /* An enumeration to specify the format of kerning values returned by */
3372+ /* @FT_Get_Kerning. */
3373+ /* */
3374+ /* <Values> */
3375+ /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */
3376+ /* 26.6 fractional pixels. */
3377+ /* */
3378+ /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */
3379+ /* 26.6 fractional pixels. */
3380+ /* */
3381+ /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */
3382+ /* units. */
3383+ /* */
3384+ /* <Note> */
3385+ /* FT_KERNING_DEFAULT returns full pixel values; it also makes */
3386+ /* FreeType heuristically scale down kerning distances at small ppem */
3387+ /* values so that they don't become too big. */
3388+ /* */
3389+ /* Both FT_KERNING_DEFAULT and FT_KERNING_UNFITTED use the current */
3390+ /* horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to */
3391+ /* convert font units to pixels. */
3392+ /* */
3393+ typedef enum FT_Kerning_Mode_
3394+ {
3395+ FT_KERNING_DEFAULT = 0,
3396+ FT_KERNING_UNFITTED,
3397+ FT_KERNING_UNSCALED
3398+
3399+ } FT_Kerning_Mode;
3400+
3401+
3402+ /* these constants are deprecated; use the corresponding */
3403+ /* `FT_Kerning_Mode' values instead */
3404+#define ft_kerning_default FT_KERNING_DEFAULT
3405+#define ft_kerning_unfitted FT_KERNING_UNFITTED
3406+#define ft_kerning_unscaled FT_KERNING_UNSCALED
3407+
3408+
3409+ /*************************************************************************/
3410+ /* */
3411+ /* <Function> */
3412+ /* FT_Get_Kerning */
3413+ /* */
3414+ /* <Description> */
3415+ /* Return the kerning vector between two glyphs of the same face. */
3416+ /* */
3417+ /* <Input> */
3418+ /* face :: A handle to a source face object. */
3419+ /* */
3420+ /* left_glyph :: The index of the left glyph in the kern pair. */
3421+ /* */
3422+ /* right_glyph :: The index of the right glyph in the kern pair. */
3423+ /* */
3424+ /* kern_mode :: See @FT_Kerning_Mode for more information. */
3425+ /* Determines the scale and dimension of the returned */
3426+ /* kerning vector. */
3427+ /* */
3428+ /* <Output> */
3429+ /* akerning :: The kerning vector. This is either in font units, */
3430+ /* fractional pixels (26.6 format), or pixels for */
3431+ /* scalable formats, and in pixels for fixed-sizes */
3432+ /* formats. */
3433+ /* */
3434+ /* <Return> */
3435+ /* FreeType error code. 0~means success. */
3436+ /* */
3437+ /* <Note> */
3438+ /* Only horizontal layouts (left-to-right & right-to-left) are */
3439+ /* supported by this method. Other layouts, or more sophisticated */
3440+ /* kernings, are out of the scope of this API function -- they can be */
3441+ /* implemented through format-specific interfaces. */
3442+ /* */
3443+ /* Kerning for OpenType fonts implemented in a `GPOS' table is not */
3444+ /* supported; use @FT_HAS_KERNING to find out whether a font has data */
3445+ /* that can be extracted with `FT_Get_Kerning'. */
3446+ /* */
3447+ FT_EXPORT( FT_Error )
3448+ FT_Get_Kerning( FT_Face face,
3449+ FT_UInt left_glyph,
3450+ FT_UInt right_glyph,
3451+ FT_UInt kern_mode,
3452+ FT_Vector *akerning );
3453+
3454+
3455+ /*************************************************************************/
3456+ /* */
3457+ /* <Function> */
3458+ /* FT_Get_Track_Kerning */
3459+ /* */
3460+ /* <Description> */
3461+ /* Return the track kerning for a given face object at a given size. */
3462+ /* */
3463+ /* <Input> */
3464+ /* face :: A handle to a source face object. */
3465+ /* */
3466+ /* point_size :: The point size in 16.16 fractional points. */
3467+ /* */
3468+ /* degree :: The degree of tightness. Increasingly negative */
3469+ /* values represent tighter track kerning, while */
3470+ /* increasingly positive values represent looser track */
3471+ /* kerning. Value zero means no track kerning. */
3472+ /* */
3473+ /* <Output> */
3474+ /* akerning :: The kerning in 16.16 fractional points, to be */
3475+ /* uniformly applied between all glyphs. */
3476+ /* */
3477+ /* <Return> */
3478+ /* FreeType error code. 0~means success. */
3479+ /* */
3480+ /* <Note> */
3481+ /* Currently, only the Type~1 font driver supports track kerning, */
3482+ /* using data from AFM files (if attached with @FT_Attach_File or */
3483+ /* @FT_Attach_Stream). */
3484+ /* */
3485+ /* Only very few AFM files come with track kerning data; please refer */
3486+ /* to Adobe's AFM specification for more details. */
3487+ /* */
3488+ FT_EXPORT( FT_Error )
3489+ FT_Get_Track_Kerning( FT_Face face,
3490+ FT_Fixed point_size,
3491+ FT_Int degree,
3492+ FT_Fixed* akerning );
3493+
3494+
3495+ /*************************************************************************/
3496+ /* */
3497+ /* <Function> */
3498+ /* FT_Get_Glyph_Name */
3499+ /* */
3500+ /* <Description> */
3501+ /* Retrieve the ASCII name of a given glyph in a face. This only */
3502+ /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */
3503+ /* */
3504+ /* <Input> */
3505+ /* face :: A handle to a source face object. */
3506+ /* */
3507+ /* glyph_index :: The glyph index. */
3508+ /* */
3509+ /* buffer_max :: The maximum number of bytes available in the */
3510+ /* buffer. */
3511+ /* */
3512+ /* <Output> */
3513+ /* buffer :: A pointer to a target buffer where the name is */
3514+ /* copied to. */
3515+ /* */
3516+ /* <Return> */
3517+ /* FreeType error code. 0~means success. */
3518+ /* */
3519+ /* <Note> */
3520+ /* An error is returned if the face doesn't provide glyph names or if */
3521+ /* the glyph index is invalid. In all cases of failure, the first */
3522+ /* byte of `buffer' is set to~0 to indicate an empty name. */
3523+ /* */
3524+ /* The glyph name is truncated to fit within the buffer if it is too */
3525+ /* long. The returned string is always zero-terminated. */
3526+ /* */
3527+ /* Be aware that FreeType reorders glyph indices internally so that */
3528+ /* glyph index~0 always corresponds to the `missing glyph' (called */
3529+ /* `.notdef'). */
3530+ /* */
3531+ /* This function always returns an error if the config macro */
3532+ /* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoption.h'. */
3533+ /* */
3534+ FT_EXPORT( FT_Error )
3535+ FT_Get_Glyph_Name( FT_Face face,
3536+ FT_UInt glyph_index,
3537+ FT_Pointer buffer,
3538+ FT_UInt buffer_max );
3539+
3540+
3541+ /*************************************************************************/
3542+ /* */
3543+ /* <Function> */
3544+ /* FT_Get_Postscript_Name */
3545+ /* */
3546+ /* <Description> */
3547+ /* Retrieve the ASCII PostScript name of a given face, if available. */
3548+ /* This only works with PostScript, TrueType, and OpenType fonts. */
3549+ /* */
3550+ /* <Input> */
3551+ /* face :: A handle to the source face object. */
3552+ /* */
3553+ /* <Return> */
3554+ /* A pointer to the face's PostScript name. NULL if unavailable. */
3555+ /* */
3556+ /* <Note> */
3557+ /* The returned pointer is owned by the face and is destroyed with */
3558+ /* it. */
3559+ /* */
3560+ /* For variation fonts, this string changes if you select a different */
3561+ /* instance, and you have to call `FT_Get_PostScript_Name' again to */
3562+ /* retrieve it. FreeType follows Adobe TechNote #5902, `Generating */
3563+ /* PostScript Names for Fonts Using OpenType Font Variations'. */
3564+ /* */
3565+ /* https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html */
3566+ /* */
3567+ /* [Since 2.9] Special PostScript names for named instances are only */
3568+ /* returned if the named instance is set with @FT_Set_Named_Instance */
3569+ /* (and the font has corresponding entries in its `fvar' table). If */
3570+ /* @FT_IS_VARIATION returns true, the algorithmically derived */
3571+ /* PostScript name is provided, not looking up special entries for */
3572+ /* named instances. */
3573+ /* */
3574+ FT_EXPORT( const char* )
3575+ FT_Get_Postscript_Name( FT_Face face );
3576+
3577+
3578+ /*************************************************************************/
3579+ /* */
3580+ /* <Function> */
3581+ /* FT_Select_Charmap */
3582+ /* */
3583+ /* <Description> */
3584+ /* Select a given charmap by its encoding tag (as listed in */
3585+ /* `freetype.h'). */
3586+ /* */
3587+ /* <InOut> */
3588+ /* face :: A handle to the source face object. */
3589+ /* */
3590+ /* <Input> */
3591+ /* encoding :: A handle to the selected encoding. */
3592+ /* */
3593+ /* <Return> */
3594+ /* FreeType error code. 0~means success. */
3595+ /* */
3596+ /* <Note> */
3597+ /* This function returns an error if no charmap in the face */
3598+ /* corresponds to the encoding queried here. */
3599+ /* */
3600+ /* Because many fonts contain more than a single cmap for Unicode */
3601+ /* encoding, this function has some special code to select the one */
3602+ /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */
3603+ /* preferred to a UCS-2 cmap). It is thus preferable to */
3604+ /* @FT_Set_Charmap in this case. */
3605+ /* */
3606+ FT_EXPORT( FT_Error )
3607+ FT_Select_Charmap( FT_Face face,
3608+ FT_Encoding encoding );
3609+
3610+
3611+ /*************************************************************************/
3612+ /* */
3613+ /* <Function> */
3614+ /* FT_Set_Charmap */
3615+ /* */
3616+ /* <Description> */
3617+ /* Select a given charmap for character code to glyph index mapping. */
3618+ /* */
3619+ /* <InOut> */
3620+ /* face :: A handle to the source face object. */
3621+ /* */
3622+ /* <Input> */
3623+ /* charmap :: A handle to the selected charmap. */
3624+ /* */
3625+ /* <Return> */
3626+ /* FreeType error code. 0~means success. */
3627+ /* */
3628+ /* <Note> */
3629+ /* This function returns an error if the charmap is not part of */
3630+ /* the face (i.e., if it is not listed in the `face->charmaps' */
3631+ /* table). */
3632+ /* */
3633+ /* It also fails if an OpenType type~14 charmap is selected (which */
3634+ /* doesn't map character codes to glyph indices at all). */
3635+ /* */
3636+ FT_EXPORT( FT_Error )
3637+ FT_Set_Charmap( FT_Face face,
3638+ FT_CharMap charmap );
3639+
3640+
3641+ /*************************************************************************
3642+ *
3643+ * @function:
3644+ * FT_Get_Charmap_Index
3645+ *
3646+ * @description:
3647+ * Retrieve index of a given charmap.
3648+ *
3649+ * @input:
3650+ * charmap ::
3651+ * A handle to a charmap.
3652+ *
3653+ * @return:
3654+ * The index into the array of character maps within the face to which
3655+ * `charmap' belongs. If an error occurs, -1 is returned.
3656+ *
3657+ */
3658+ FT_EXPORT( FT_Int )
3659+ FT_Get_Charmap_Index( FT_CharMap charmap );
3660+
3661+
3662+ /*************************************************************************/
3663+ /* */
3664+ /* <Function> */
3665+ /* FT_Get_Char_Index */
3666+ /* */
3667+ /* <Description> */
3668+ /* Return the glyph index of a given character code. This function */
3669+ /* uses the currently selected charmap to do the mapping. */
3670+ /* */
3671+ /* <Input> */
3672+ /* face :: A handle to the source face object. */
3673+ /* */
3674+ /* charcode :: The character code. */
3675+ /* */
3676+ /* <Return> */
3677+ /* The glyph index. 0~means `undefined character code'. */
3678+ /* */
3679+ /* <Note> */
3680+ /* If you use FreeType to manipulate the contents of font files */
3681+ /* directly, be aware that the glyph index returned by this function */
3682+ /* doesn't always correspond to the internal indices used within the */
3683+ /* file. This is done to ensure that value~0 always corresponds to */
3684+ /* the `missing glyph'. If the first glyph is not named `.notdef', */
3685+ /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */
3686+ /* the glyph ID~0 position, and whatever was there will be moved to */
3687+ /* the position `.notdef' had. For Type~1 fonts, if there is no */
3688+ /* `.notdef' glyph at all, then one will be created at index~0 and */
3689+ /* whatever was there will be moved to the last index -- Type~42 */
3690+ /* fonts are considered invalid under this condition. */
3691+ /* */
3692+ FT_EXPORT( FT_UInt )
3693+ FT_Get_Char_Index( FT_Face face,
3694+ FT_ULong charcode );
3695+
3696+
3697+ /*************************************************************************/
3698+ /* */
3699+ /* <Function> */
3700+ /* FT_Get_First_Char */
3701+ /* */
3702+ /* <Description> */
3703+ /* Return the first character code in the current charmap of a given */
3704+ /* face, together with its corresponding glyph index. */
3705+ /* */
3706+ /* <Input> */
3707+ /* face :: A handle to the source face object. */
3708+ /* */
3709+ /* <Output> */
3710+ /* agindex :: Glyph index of first character code. 0~if charmap is */
3711+ /* empty. */
3712+ /* */
3713+ /* <Return> */
3714+ /* The charmap's first character code. */
3715+ /* */
3716+ /* <Note> */
3717+ /* You should use this function together with @FT_Get_Next_Char to */
3718+ /* parse all character codes available in a given charmap. The code */
3719+ /* should look like this: */
3720+ /* */
3721+ /* { */
3722+ /* FT_ULong charcode; */
3723+ /* FT_UInt gindex; */
3724+ /* */
3725+ /* */
3726+ /* charcode = FT_Get_First_Char( face, &gindex ); */
3727+ /* while ( gindex != 0 ) */
3728+ /* { */
3729+ /* ... do something with (charcode,gindex) pair ... */
3730+ /* */
3731+ /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
3732+ /* } */
3733+ /* } */
3734+ /* */
3735+ /* Be aware that character codes can have values up to 0xFFFFFFFF; */
3736+ /* this might happen for non-Unicode or malformed cmaps. However, */
3737+ /* even with regular Unicode encoding, so-called `last resort fonts' */
3738+ /* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */
3739+ /* normally have entries for all Unicode characters up to 0x1FFFFF, */
3740+ /* which can cause *a lot* of iterations. */
3741+ /* */
3742+ /* Note that `*agindex' is set to~0 if the charmap is empty. The */
3743+ /* result itself can be~0 in two cases: if the charmap is empty or */
3744+ /* if the value~0 is the first valid character code. */
3745+ /* */
3746+ FT_EXPORT( FT_ULong )
3747+ FT_Get_First_Char( FT_Face face,
3748+ FT_UInt *agindex );
3749+
3750+
3751+ /*************************************************************************/
3752+ /* */
3753+ /* <Function> */
3754+ /* FT_Get_Next_Char */
3755+ /* */
3756+ /* <Description> */
3757+ /* Return the next character code in the current charmap of a given */
3758+ /* face following the value `char_code', as well as the corresponding */
3759+ /* glyph index. */
3760+ /* */
3761+ /* <Input> */
3762+ /* face :: A handle to the source face object. */
3763+ /* */
3764+ /* char_code :: The starting character code. */
3765+ /* */
3766+ /* <Output> */
3767+ /* agindex :: Glyph index of next character code. 0~if charmap */
3768+ /* is empty. */
3769+ /* */
3770+ /* <Return> */
3771+ /* The charmap's next character code. */
3772+ /* */
3773+ /* <Note> */
3774+ /* You should use this function with @FT_Get_First_Char to walk */
3775+ /* over all character codes available in a given charmap. See the */
3776+ /* note for that function for a simple code example. */
3777+ /* */
3778+ /* Note that `*agindex' is set to~0 when there are no more codes in */
3779+ /* the charmap. */
3780+ /* */
3781+ FT_EXPORT( FT_ULong )
3782+ FT_Get_Next_Char( FT_Face face,
3783+ FT_ULong char_code,
3784+ FT_UInt *agindex );
3785+
3786+
3787+ /*************************************************************************
3788+ *
3789+ * @function:
3790+ * FT_Face_Properties
3791+ *
3792+ * @description:
3793+ * Set or override certain (library or module-wide) properties on a
3794+ * face-by-face basis. Useful for finer-grained control and avoiding
3795+ * locks on shared structures (threads can modify their own faces as
3796+ * they see fit).
3797+ *
3798+ * Contrary to @FT_Property_Set, this function uses @FT_Parameter so
3799+ * that you can pass multiple properties to the target face in one call.
3800+ * Note that only a subset of the available properties can be
3801+ * controlled.
3802+ *
3803+ * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the
3804+ * property `no-stem-darkening' provided by the `autofit', `cff',
3805+ * `type1', and `t1cid' modules; see @no-stem-darkening).
3806+ *
3807+ * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding
3808+ * to function @FT_Library_SetLcdFilterWeights).
3809+ *
3810+ * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID
3811+ * `random' operator, corresponding to the `random-seed' property
3812+ * provided by the `cff', `type1', and `t1cid' modules; see
3813+ * @random-seed).
3814+ *
3815+ * Pass NULL as `data' in @FT_Parameter for a given tag to reset the
3816+ * option and use the library or module default again.
3817+ *
3818+ * @input:
3819+ * face ::
3820+ * A handle to the source face object.
3821+ *
3822+ * num_properties ::
3823+ * The number of properties that follow.
3824+ *
3825+ * properties ::
3826+ * A handle to an @FT_Parameter array with `num_properties' elements.
3827+ *
3828+ * @return:
3829+ * FreeType error code. 0~means success.
3830+ *
3831+ * @note:
3832+ * Here an example that sets three properties. You must define
3833+ * FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples
3834+ * work.
3835+ *
3836+ * {
3837+ * FT_Parameter property1;
3838+ * FT_Bool darken_stems = 1;
3839+ *
3840+ * FT_Parameter property2;
3841+ * FT_LcdFiveTapFilter custom_weight =
3842+ * { 0x11, 0x44, 0x56, 0x44, 0x11 };
3843+ *
3844+ * FT_Parameter property3;
3845+ * FT_Int32 random_seed = 314159265;
3846+ *
3847+ * FT_Parameter properties[3] = { property1,
3848+ * property2,
3849+ * property3 };
3850+ *
3851+ *
3852+ * property1.tag = FT_PARAM_TAG_STEM_DARKENING;
3853+ * property1.data = &darken_stems;
3854+ *
3855+ * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
3856+ * property2.data = custom_weight;
3857+ *
3858+ * property3.tag = FT_PARAM_TAG_RANDOM_SEED;
3859+ * property3.data = &random_seed;
3860+ *
3861+ * FT_Face_Properties( face, 3, properties );
3862+ * }
3863+ *
3864+ * The next example resets a single property to its default value.
3865+ *
3866+ * {
3867+ * FT_Parameter property;
3868+ *
3869+ *
3870+ * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
3871+ * property.data = NULL;
3872+ *
3873+ * FT_Face_Properties( face, 1, &property );
3874+ * }
3875+ *
3876+ * @since:
3877+ * 2.8
3878+ *
3879+ */
3880+ FT_EXPORT( FT_Error )
3881+ FT_Face_Properties( FT_Face face,
3882+ FT_UInt num_properties,
3883+ FT_Parameter* properties );
3884+
3885+
3886+ /*************************************************************************/
3887+ /* */
3888+ /* <Function> */
3889+ /* FT_Get_Name_Index */
3890+ /* */
3891+ /* <Description> */
3892+ /* Return the glyph index of a given glyph name. */
3893+ /* */
3894+ /* <Input> */
3895+ /* face :: A handle to the source face object. */
3896+ /* */
3897+ /* glyph_name :: The glyph name. */
3898+ /* */
3899+ /* <Return> */
3900+ /* The glyph index. 0~means `undefined character code'. */
3901+ /* */
3902+ FT_EXPORT( FT_UInt )
3903+ FT_Get_Name_Index( FT_Face face,
3904+ FT_String* glyph_name );
3905+
3906+
3907+ /*************************************************************************
3908+ *
3909+ * @macro:
3910+ * FT_SUBGLYPH_FLAG_XXX
3911+ *
3912+ * @description:
3913+ * A list of constants describing subglyphs. Please refer to the
3914+ * `glyf' table description in the OpenType specification for the
3915+ * meaning of the various flags (which get synthesized for
3916+ * non-OpenType subglyphs).
3917+ *
3918+ * @values:
3919+ * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
3920+ * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
3921+ * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
3922+ * FT_SUBGLYPH_FLAG_SCALE ::
3923+ * FT_SUBGLYPH_FLAG_XY_SCALE ::
3924+ * FT_SUBGLYPH_FLAG_2X2 ::
3925+ * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
3926+ *
3927+ */
3928+#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
3929+#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
3930+#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
3931+#define FT_SUBGLYPH_FLAG_SCALE 8
3932+#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
3933+#define FT_SUBGLYPH_FLAG_2X2 0x80
3934+#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
3935+
3936+
3937+ /*************************************************************************
3938+ *
3939+ * @func:
3940+ * FT_Get_SubGlyph_Info
3941+ *
3942+ * @description:
3943+ * Retrieve a description of a given subglyph. Only use it if
3944+ * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is
3945+ * returned otherwise.
3946+ *
3947+ * @input:
3948+ * glyph ::
3949+ * The source glyph slot.
3950+ *
3951+ * sub_index ::
3952+ * The index of the subglyph. Must be less than
3953+ * `glyph->num_subglyphs'.
3954+ *
3955+ * @output:
3956+ * p_index ::
3957+ * The glyph index of the subglyph.
3958+ *
3959+ * p_flags ::
3960+ * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
3961+ *
3962+ * p_arg1 ::
3963+ * The subglyph's first argument (if any).
3964+ *
3965+ * p_arg2 ::
3966+ * The subglyph's second argument (if any).
3967+ *
3968+ * p_transform ::
3969+ * The subglyph transformation (if any).
3970+ *
3971+ * @return:
3972+ * FreeType error code. 0~means success.
3973+ *
3974+ * @note:
3975+ * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be
3976+ * interpreted depending on the flags returned in `*p_flags'. See the
3977+ * OpenType specification for details.
3978+ *
3979+ */
3980+ FT_EXPORT( FT_Error )
3981+ FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
3982+ FT_UInt sub_index,
3983+ FT_Int *p_index,
3984+ FT_UInt *p_flags,
3985+ FT_Int *p_arg1,
3986+ FT_Int *p_arg2,
3987+ FT_Matrix *p_transform );
3988+
3989+
3990+ /*************************************************************************/
3991+ /* */
3992+ /* <Enum> */
3993+ /* FT_FSTYPE_XXX */
3994+ /* */
3995+ /* <Description> */
3996+ /* A list of bit flags used in the `fsType' field of the OS/2 table */
3997+ /* in a TrueType or OpenType font and the `FSType' entry in a */
3998+ /* PostScript font. These bit flags are returned by */
3999+ /* @FT_Get_FSType_Flags; they inform client applications of embedding */
4000+ /* and subsetting restrictions associated with a font. */
4001+ /* */
4002+ /* See */
4003+ /* https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */
4004+ /* for more details. */
4005+ /* */
4006+ /* <Values> */
4007+ /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */
4008+ /* Fonts with no fsType bit set may be embedded and permanently */
4009+ /* installed on the remote system by an application. */
4010+ /* */
4011+ /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */
4012+ /* Fonts that have only this bit set must not be modified, embedded */
4013+ /* or exchanged in any manner without first obtaining permission of */
4014+ /* the font software copyright owner. */
4015+ /* */
4016+ /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */
4017+ /* The font may be embedded and temporarily loaded on the remote */
4018+ /* system. Documents containing Preview & Print fonts must be */
4019+ /* opened `read-only'; no edits can be applied to the document. */
4020+ /* */
4021+ /* FT_FSTYPE_EDITABLE_EMBEDDING :: */
4022+ /* The font may be embedded but must only be installed temporarily */
4023+ /* on other systems. In contrast to Preview & Print fonts, */
4024+ /* documents containing editable fonts may be opened for reading, */
4025+ /* editing is permitted, and changes may be saved. */
4026+ /* */
4027+ /* FT_FSTYPE_NO_SUBSETTING :: */
4028+ /* The font may not be subsetted prior to embedding. */
4029+ /* */
4030+ /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */
4031+ /* Only bitmaps contained in the font may be embedded; no outline */
4032+ /* data may be embedded. If there are no bitmaps available in the */
4033+ /* font, then the font is unembeddable. */
4034+ /* */
4035+ /* <Note> */
4036+ /* The flags are ORed together, thus more than a single value can be */
4037+ /* returned. */
4038+ /* */
4039+ /* While the `fsType' flags can indicate that a font may be embedded, */
4040+ /* a license with the font vendor may be separately required to use */
4041+ /* the font in this way. */
4042+ /* */
4043+#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
4044+#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
4045+#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
4046+#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
4047+#define FT_FSTYPE_NO_SUBSETTING 0x0100
4048+#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
4049+
4050+
4051+ /*************************************************************************/
4052+ /* */
4053+ /* <Function> */
4054+ /* FT_Get_FSType_Flags */
4055+ /* */
4056+ /* <Description> */
4057+ /* Return the `fsType' flags for a font. */
4058+ /* */
4059+ /* <Input> */
4060+ /* face :: A handle to the source face object. */
4061+ /* */
4062+ /* <Return> */
4063+ /* The `fsType' flags, see @FT_FSTYPE_XXX. */
4064+ /* */
4065+ /* <Note> */
4066+ /* Use this function rather than directly reading the `fs_type' field */
4067+ /* in the @PS_FontInfoRec structure, which is only guaranteed to */
4068+ /* return the correct results for Type~1 fonts. */
4069+ /* */
4070+ /* <Since> */
4071+ /* 2.3.8 */
4072+ /* */
4073+ FT_EXPORT( FT_UShort )
4074+ FT_Get_FSType_Flags( FT_Face face );
4075+
4076+
4077+ /*************************************************************************/
4078+ /* */
4079+ /* <Section> */
4080+ /* glyph_variants */
4081+ /* */
4082+ /* <Title> */
4083+ /* Unicode Variation Sequences */
4084+ /* */
4085+ /* <Abstract> */
4086+ /* The FreeType~2 interface to Unicode Variation Sequences (UVS), */
4087+ /* using the SFNT cmap format~14. */
4088+ /* */
4089+ /* <Description> */
4090+ /* Many characters, especially for CJK scripts, have variant forms. */
4091+ /* They are a sort of grey area somewhere between being totally */
4092+ /* irrelevant and semantically distinct; for this reason, the Unicode */
4093+ /* consortium decided to introduce Variation Sequences (VS), */
4094+ /* consisting of a Unicode base character and a variation selector */
4095+ /* instead of further extending the already huge number of */
4096+ /* characters. */
4097+ /* */
4098+ /* Unicode maintains two different sets, namely `Standardized */
4099+ /* Variation Sequences' and registered `Ideographic Variation */
4100+ /* Sequences' (IVS), collected in the `Ideographic Variation */
4101+ /* Database' (IVD). */
4102+ /* */
4103+ /* https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt */
4104+ /* https://unicode.org/reports/tr37/ */
4105+ /* https://unicode.org/ivd/ */
4106+ /* */
4107+ /* To date (January 2017), the character with the most ideographic */
4108+ /* variations is U+9089, having 32 such IVS. */
4109+ /* */
4110+ /* Three Mongolian Variation Selectors have the values U+180B-U+180D; */
4111+ /* 256 generic Variation Selectors are encoded in the ranges */
4112+ /* U+FE00-U+FE0F and U+E0100-U+E01EF. IVS currently use Variation */
4113+ /* Selectors from the range U+E0100-U+E01EF only. */
4114+ /* */
4115+ /* A VS consists of the base character value followed by a single */
4116+ /* Variation Selector. For example, to get the first variation of */
4117+ /* U+9089, you have to write the character sequence `U+9089 U+E0100'. */
4118+ /* */
4119+ /* Adobe and MS decided to support both standardized and ideographic */
4120+ /* VS with a new cmap subtable (format~14). It is an odd subtable */
4121+ /* because it is not a mapping of input code points to glyphs, but */
4122+ /* contains lists of all variations supported by the font. */
4123+ /* */
4124+ /* A variation may be either `default' or `non-default' for a given */
4125+ /* font. A default variation is the one you will get for that code */
4126+ /* point if you look it up in the standard Unicode cmap. A */
4127+ /* non-default variation is a different glyph. */
4128+ /* */
4129+ /*************************************************************************/
4130+
4131+
4132+ /*************************************************************************/
4133+ /* */
4134+ /* <Function> */
4135+ /* FT_Face_GetCharVariantIndex */
4136+ /* */
4137+ /* <Description> */
4138+ /* Return the glyph index of a given character code as modified by */
4139+ /* the variation selector. */
4140+ /* */
4141+ /* <Input> */
4142+ /* face :: */
4143+ /* A handle to the source face object. */
4144+ /* */
4145+ /* charcode :: */
4146+ /* The character code point in Unicode. */
4147+ /* */
4148+ /* variantSelector :: */
4149+ /* The Unicode code point of the variation selector. */
4150+ /* */
4151+ /* <Return> */
4152+ /* The glyph index. 0~means either `undefined character code', or */
4153+ /* `undefined selector code', or `no variation selector cmap */
4154+ /* subtable', or `current CharMap is not Unicode'. */
4155+ /* */
4156+ /* <Note> */
4157+ /* If you use FreeType to manipulate the contents of font files */
4158+ /* directly, be aware that the glyph index returned by this function */
4159+ /* doesn't always correspond to the internal indices used within */
4160+ /* the file. This is done to ensure that value~0 always corresponds */
4161+ /* to the `missing glyph'. */
4162+ /* */
4163+ /* This function is only meaningful if */
4164+ /* a) the font has a variation selector cmap sub table, */
4165+ /* and */
4166+ /* b) the current charmap has a Unicode encoding. */
4167+ /* */
4168+ /* <Since> */
4169+ /* 2.3.6 */
4170+ /* */
4171+ FT_EXPORT( FT_UInt )
4172+ FT_Face_GetCharVariantIndex( FT_Face face,
4173+ FT_ULong charcode,
4174+ FT_ULong variantSelector );
4175+
4176+
4177+ /*************************************************************************/
4178+ /* */
4179+ /* <Function> */
4180+ /* FT_Face_GetCharVariantIsDefault */
4181+ /* */
4182+ /* <Description> */
4183+ /* Check whether this variation of this Unicode character is the one */
4184+ /* to be found in the `cmap'. */
4185+ /* */
4186+ /* <Input> */
4187+ /* face :: */
4188+ /* A handle to the source face object. */
4189+ /* */
4190+ /* charcode :: */
4191+ /* The character codepoint in Unicode. */
4192+ /* */
4193+ /* variantSelector :: */
4194+ /* The Unicode codepoint of the variation selector. */
4195+ /* */
4196+ /* <Return> */
4197+ /* 1~if found in the standard (Unicode) cmap, 0~if found in the */
4198+ /* variation selector cmap, or -1 if it is not a variation. */
4199+ /* */
4200+ /* <Note> */
4201+ /* This function is only meaningful if the font has a variation */
4202+ /* selector cmap subtable. */
4203+ /* */
4204+ /* <Since> */
4205+ /* 2.3.6 */
4206+ /* */
4207+ FT_EXPORT( FT_Int )
4208+ FT_Face_GetCharVariantIsDefault( FT_Face face,
4209+ FT_ULong charcode,
4210+ FT_ULong variantSelector );
4211+
4212+
4213+ /*************************************************************************/
4214+ /* */
4215+ /* <Function> */
4216+ /* FT_Face_GetVariantSelectors */
4217+ /* */
4218+ /* <Description> */
4219+ /* Return a zero-terminated list of Unicode variation selectors found */
4220+ /* in the font. */
4221+ /* */
4222+ /* <Input> */
4223+ /* face :: */
4224+ /* A handle to the source face object. */
4225+ /* */
4226+ /* <Return> */
4227+ /* A pointer to an array of selector code points, or NULL if there is */
4228+ /* no valid variation selector cmap subtable. */
4229+ /* */
4230+ /* <Note> */
4231+ /* The last item in the array is~0; the array is owned by the */
4232+ /* @FT_Face object but can be overwritten or released on the next */
4233+ /* call to a FreeType function. */
4234+ /* */
4235+ /* <Since> */
4236+ /* 2.3.6 */
4237+ /* */
4238+ FT_EXPORT( FT_UInt32* )
4239+ FT_Face_GetVariantSelectors( FT_Face face );
4240+
4241+
4242+ /*************************************************************************/
4243+ /* */
4244+ /* <Function> */
4245+ /* FT_Face_GetVariantsOfChar */
4246+ /* */
4247+ /* <Description> */
4248+ /* Return a zero-terminated list of Unicode variation selectors found */
4249+ /* for the specified character code. */
4250+ /* */
4251+ /* <Input> */
4252+ /* face :: */
4253+ /* A handle to the source face object. */
4254+ /* */
4255+ /* charcode :: */
4256+ /* The character codepoint in Unicode. */
4257+ /* */
4258+ /* <Return> */
4259+ /* A pointer to an array of variation selector code points that are */
4260+ /* active for the given character, or NULL if the corresponding list */
4261+ /* is empty. */
4262+ /* */
4263+ /* <Note> */
4264+ /* The last item in the array is~0; the array is owned by the */
4265+ /* @FT_Face object but can be overwritten or released on the next */
4266+ /* call to a FreeType function. */
4267+ /* */
4268+ /* <Since> */
4269+ /* 2.3.6 */
4270+ /* */
4271+ FT_EXPORT( FT_UInt32* )
4272+ FT_Face_GetVariantsOfChar( FT_Face face,
4273+ FT_ULong charcode );
4274+
4275+
4276+ /*************************************************************************/
4277+ /* */
4278+ /* <Function> */
4279+ /* FT_Face_GetCharsOfVariant */
4280+ /* */
4281+ /* <Description> */
4282+ /* Return a zero-terminated list of Unicode character codes found for */
4283+ /* the specified variation selector. */
4284+ /* */
4285+ /* <Input> */
4286+ /* face :: */
4287+ /* A handle to the source face object. */
4288+ /* */
4289+ /* variantSelector :: */
4290+ /* The variation selector code point in Unicode. */
4291+ /* */
4292+ /* <Return> */
4293+ /* A list of all the code points that are specified by this selector */
4294+ /* (both default and non-default codes are returned) or NULL if there */
4295+ /* is no valid cmap or the variation selector is invalid. */
4296+ /* */
4297+ /* <Note> */
4298+ /* The last item in the array is~0; the array is owned by the */
4299+ /* @FT_Face object but can be overwritten or released on the next */
4300+ /* call to a FreeType function. */
4301+ /* */
4302+ /* <Since> */
4303+ /* 2.3.6 */
4304+ /* */
4305+ FT_EXPORT( FT_UInt32* )
4306+ FT_Face_GetCharsOfVariant( FT_Face face,
4307+ FT_ULong variantSelector );
4308+
4309+
4310+ /*************************************************************************/
4311+ /* */
4312+ /* <Section> */
4313+ /* computations */
4314+ /* */
4315+ /* <Title> */
4316+ /* Computations */
4317+ /* */
4318+ /* <Abstract> */
4319+ /* Crunching fixed numbers and vectors. */
4320+ /* */
4321+ /* <Description> */
4322+ /* This section contains various functions used to perform */
4323+ /* computations on 16.16 fixed-float numbers or 2d vectors. */
4324+ /* */
4325+ /* <Order> */
4326+ /* FT_MulDiv */
4327+ /* FT_MulFix */
4328+ /* FT_DivFix */
4329+ /* FT_RoundFix */
4330+ /* FT_CeilFix */
4331+ /* FT_FloorFix */
4332+ /* FT_Vector_Transform */
4333+ /* FT_Matrix_Multiply */
4334+ /* FT_Matrix_Invert */
4335+ /* */
4336+ /*************************************************************************/
4337+
4338+
4339+ /*************************************************************************/
4340+ /* */
4341+ /* <Function> */
4342+ /* FT_MulDiv */
4343+ /* */
4344+ /* <Description> */
4345+ /* Compute `(a*b)/c' with maximum accuracy, using a 64-bit */
4346+ /* intermediate integer whenever necessary. */
4347+ /* */
4348+ /* This function isn't necessarily as fast as some processor specific */
4349+ /* operations, but is at least completely portable. */
4350+ /* */
4351+ /* <Input> */
4352+ /* a :: The first multiplier. */
4353+ /* */
4354+ /* b :: The second multiplier. */
4355+ /* */
4356+ /* c :: The divisor. */
4357+ /* */
4358+ /* <Return> */
4359+ /* The result of `(a*b)/c'. This function never traps when trying to */
4360+ /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
4361+ /* on the signs of `a' and `b'. */
4362+ /* */
4363+ FT_EXPORT( FT_Long )
4364+ FT_MulDiv( FT_Long a,
4365+ FT_Long b,
4366+ FT_Long c );
4367+
4368+
4369+ /*************************************************************************/
4370+ /* */
4371+ /* <Function> */
4372+ /* FT_MulFix */
4373+ /* */
4374+ /* <Description> */
4375+ /* Compute `(a*b)/0x10000' with maximum accuracy. Its main use is to */
4376+ /* multiply a given value by a 16.16 fixed-point factor. */
4377+ /* */
4378+ /* <Input> */
4379+ /* a :: The first multiplier. */
4380+ /* */
4381+ /* b :: The second multiplier. Use a 16.16 factor here whenever */
4382+ /* possible (see note below). */
4383+ /* */
4384+ /* <Return> */
4385+ /* The result of `(a*b)/0x10000'. */
4386+ /* */
4387+ /* <Note> */
4388+ /* This function has been optimized for the case where the absolute */
4389+ /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
4390+ /* As this happens mainly when scaling from notional units to */
4391+ /* fractional pixels in FreeType, it resulted in noticeable speed */
4392+ /* improvements between versions 2.x and 1.x. */
4393+ /* */
4394+ /* As a conclusion, always try to place a 16.16 factor as the */
4395+ /* _second_ argument of this function; this can make a great */
4396+ /* difference. */
4397+ /* */
4398+ FT_EXPORT( FT_Long )
4399+ FT_MulFix( FT_Long a,
4400+ FT_Long b );
4401+
4402+
4403+ /*************************************************************************/
4404+ /* */
4405+ /* <Function> */
4406+ /* FT_DivFix */
4407+ /* */
4408+ /* <Description> */
4409+ /* Compute `(a*0x10000)/b' with maximum accuracy. Its main use is to */
4410+ /* divide a given value by a 16.16 fixed-point factor. */
4411+ /* */
4412+ /* <Input> */
4413+ /* a :: The numerator. */
4414+ /* */
4415+ /* b :: The denominator. Use a 16.16 factor here. */
4416+ /* */
4417+ /* <Return> */
4418+ /* The result of `(a*0x10000)/b'. */
4419+ /* */
4420+ FT_EXPORT( FT_Long )
4421+ FT_DivFix( FT_Long a,
4422+ FT_Long b );
4423+
4424+
4425+ /*************************************************************************/
4426+ /* */
4427+ /* <Function> */
4428+ /* FT_RoundFix */
4429+ /* */
4430+ /* <Description> */
4431+ /* Round a 16.16 fixed number. */
4432+ /* */
4433+ /* <Input> */
4434+ /* a :: The number to be rounded. */
4435+ /* */
4436+ /* <Return> */
4437+ /* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */
4438+ /* from zero. */
4439+ /* */
4440+ /* <Note> */
4441+ /* The function uses wrap-around arithmetic. */
4442+ /* */
4443+ FT_EXPORT( FT_Fixed )
4444+ FT_RoundFix( FT_Fixed a );
4445+
4446+
4447+ /*************************************************************************/
4448+ /* */
4449+ /* <Function> */
4450+ /* FT_CeilFix */
4451+ /* */
4452+ /* <Description> */
4453+ /* Compute the smallest following integer of a 16.16 fixed number. */
4454+ /* */
4455+ /* <Input> */
4456+ /* a :: The number for which the ceiling function is to be computed. */
4457+ /* */
4458+ /* <Return> */
4459+ /* `a' rounded towards plus infinity. */
4460+ /* */
4461+ /* <Note> */
4462+ /* The function uses wrap-around arithmetic. */
4463+ /* */
4464+ FT_EXPORT( FT_Fixed )
4465+ FT_CeilFix( FT_Fixed a );
4466+
4467+
4468+ /*************************************************************************/
4469+ /* */
4470+ /* <Function> */
4471+ /* FT_FloorFix */
4472+ /* */
4473+ /* <Description> */
4474+ /* Compute the largest previous integer of a 16.16 fixed number. */
4475+ /* */
4476+ /* <Input> */
4477+ /* a :: The number for which the floor function is to be computed. */
4478+ /* */
4479+ /* <Return> */
4480+ /* `a' rounded towards minus infinity. */
4481+ /* */
4482+ FT_EXPORT( FT_Fixed )
4483+ FT_FloorFix( FT_Fixed a );
4484+
4485+
4486+ /*************************************************************************/
4487+ /* */
4488+ /* <Function> */
4489+ /* FT_Vector_Transform */
4490+ /* */
4491+ /* <Description> */
4492+ /* Transform a single vector through a 2x2 matrix. */
4493+ /* */
4494+ /* <InOut> */
4495+ /* vector :: The target vector to transform. */
4496+ /* */
4497+ /* <Input> */
4498+ /* matrix :: A pointer to the source 2x2 matrix. */
4499+ /* */
4500+ /* <Note> */
4501+ /* The result is undefined if either `vector' or `matrix' is invalid. */
4502+ /* */
4503+ FT_EXPORT( void )
4504+ FT_Vector_Transform( FT_Vector* vec,
4505+ const FT_Matrix* matrix );
4506+
4507+
4508+ /*************************************************************************/
4509+ /* */
4510+ /* <Section> */
4511+ /* version */
4512+ /* */
4513+ /* <Title> */
4514+ /* FreeType Version */
4515+ /* */
4516+ /* <Abstract> */
4517+ /* Functions and macros related to FreeType versions. */
4518+ /* */
4519+ /* <Description> */
4520+ /* Note that those functions and macros are of limited use because */
4521+ /* even a new release of FreeType with only documentation changes */
4522+ /* increases the version number. */
4523+ /* */
4524+ /* <Order> */
4525+ /* FT_Library_Version */
4526+ /* */
4527+ /* FREETYPE_MAJOR */
4528+ /* FREETYPE_MINOR */
4529+ /* FREETYPE_PATCH */
4530+ /* */
4531+ /* FT_Face_CheckTrueTypePatents */
4532+ /* FT_Face_SetUnpatentedHinting */
4533+ /* */
4534+ /* FREETYPE_XXX */
4535+ /* */
4536+ /*************************************************************************/
4537+
4538+
4539+ /*************************************************************************
4540+ *
4541+ * @enum:
4542+ * FREETYPE_XXX
4543+ *
4544+ * @description:
4545+ * These three macros identify the FreeType source code version.
4546+ * Use @FT_Library_Version to access them at runtime.
4547+ *
4548+ * @values:
4549+ * FREETYPE_MAJOR :: The major version number.
4550+ * FREETYPE_MINOR :: The minor version number.
4551+ * FREETYPE_PATCH :: The patch level.
4552+ *
4553+ * @note:
4554+ * The version number of FreeType if built as a dynamic link library
4555+ * with the `libtool' package is _not_ controlled by these three
4556+ * macros.
4557+ *
4558+ */
4559+#define FREETYPE_MAJOR 2
4560+#define FREETYPE_MINOR 9
4561+#define FREETYPE_PATCH 1
4562+
4563+
4564+ /*************************************************************************/
4565+ /* */
4566+ /* <Function> */
4567+ /* FT_Library_Version */
4568+ /* */
4569+ /* <Description> */
4570+ /* Return the version of the FreeType library being used. This is */
4571+ /* useful when dynamically linking to the library, since one cannot */
4572+ /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */
4573+ /* @FREETYPE_PATCH. */
4574+ /* */
4575+ /* <Input> */
4576+ /* library :: A source library handle. */
4577+ /* */
4578+ /* <Output> */
4579+ /* amajor :: The major version number. */
4580+ /* */
4581+ /* aminor :: The minor version number. */
4582+ /* */
4583+ /* apatch :: The patch version number. */
4584+ /* */
4585+ /* <Note> */
4586+ /* The reason why this function takes a `library' argument is because */
4587+ /* certain programs implement library initialization in a custom way */
4588+ /* that doesn't use @FT_Init_FreeType. */
4589+ /* */
4590+ /* In such cases, the library version might not be available before */
4591+ /* the library object has been created. */
4592+ /* */
4593+ FT_EXPORT( void )
4594+ FT_Library_Version( FT_Library library,
4595+ FT_Int *amajor,
4596+ FT_Int *aminor,
4597+ FT_Int *apatch );
4598+
4599+
4600+ /*************************************************************************/
4601+ /* */
4602+ /* <Function> */
4603+ /* FT_Face_CheckTrueTypePatents */
4604+ /* */
4605+ /* <Description> */
4606+ /* Deprecated, does nothing. */
4607+ /* */
4608+ /* <Input> */
4609+ /* face :: A face handle. */
4610+ /* */
4611+ /* <Return> */
4612+ /* Always returns false. */
4613+ /* */
4614+ /* <Note> */
4615+ /* Since May 2010, TrueType hinting is no longer patented. */
4616+ /* */
4617+ /* <Since> */
4618+ /* 2.3.5 */
4619+ /* */
4620+ FT_EXPORT( FT_Bool )
4621+ FT_Face_CheckTrueTypePatents( FT_Face face );
4622+
4623+
4624+ /*************************************************************************/
4625+ /* */
4626+ /* <Function> */
4627+ /* FT_Face_SetUnpatentedHinting */
4628+ /* */
4629+ /* <Description> */
4630+ /* Deprecated, does nothing. */
4631+ /* */
4632+ /* <Input> */
4633+ /* face :: A face handle. */
4634+ /* */
4635+ /* value :: New boolean setting. */
4636+ /* */
4637+ /* <Return> */
4638+ /* Always returns false. */
4639+ /* */
4640+ /* <Note> */
4641+ /* Since May 2010, TrueType hinting is no longer patented. */
4642+ /* */
4643+ /* <Since> */
4644+ /* 2.3.5 */
4645+ /* */
4646+ FT_EXPORT( FT_Bool )
4647+ FT_Face_SetUnpatentedHinting( FT_Face face,
4648+ FT_Bool value );
4649+
4650+ /* */
4651+
4652+
4653+FT_END_HEADER
4654+
4655+#endif /* FREETYPE_H_ */
4656+
4657+
4658+/* END */
1@@ -0,0 +1,187 @@
2+/***************************************************************************/
3+/* */
4+/* ftadvanc.h */
5+/* */
6+/* Quick computation of advance widths (specification only). */
7+/* */
8+/* Copyright 2008-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTADVANC_H_
21+#define FTADVANC_H_
22+
23+
24+#include <ft2build.h>
25+#include FT_FREETYPE_H
26+
27+#ifdef FREETYPE_H
28+#error "freetype.h of FreeType 1 has been loaded!"
29+#error "Please fix the directory search order for header files"
30+#error "so that freetype.h of FreeType 2 is found first."
31+#endif
32+
33+
34+FT_BEGIN_HEADER
35+
36+
37+ /**************************************************************************
38+ *
39+ * @section:
40+ * quick_advance
41+ *
42+ * @title:
43+ * Quick retrieval of advance values
44+ *
45+ * @abstract:
46+ * Retrieve horizontal and vertical advance values without processing
47+ * glyph outlines, if possible.
48+ *
49+ * @description:
50+ * This section contains functions to quickly extract advance values
51+ * without handling glyph outlines, if possible.
52+ *
53+ * @order:
54+ * FT_Get_Advance
55+ * FT_Get_Advances
56+ *
57+ */
58+
59+
60+ /*************************************************************************/
61+ /* */
62+ /* <Const> */
63+ /* FT_ADVANCE_FLAG_FAST_ONLY */
64+ /* */
65+ /* <Description> */
66+ /* A bit-flag to be OR-ed with the `flags' parameter of the */
67+ /* @FT_Get_Advance and @FT_Get_Advances functions. */
68+ /* */
69+ /* If set, it indicates that you want these functions to fail if the */
70+ /* corresponding hinting mode or font driver doesn't allow for very */
71+ /* quick advance computation. */
72+ /* */
73+ /* Typically, glyphs that are either unscaled, unhinted, bitmapped, */
74+ /* or light-hinted can have their advance width computed very */
75+ /* quickly. */
76+ /* */
77+ /* Normal and bytecode hinted modes that require loading, scaling, */
78+ /* and hinting of the glyph outline, are extremely slow by */
79+ /* comparison. */
80+ /* */
81+#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L
82+
83+
84+ /*************************************************************************/
85+ /* */
86+ /* <Function> */
87+ /* FT_Get_Advance */
88+ /* */
89+ /* <Description> */
90+ /* Retrieve the advance value of a given glyph outline in an */
91+ /* @FT_Face. */
92+ /* */
93+ /* <Input> */
94+ /* face :: The source @FT_Face handle. */
95+ /* */
96+ /* gindex :: The glyph index. */
97+ /* */
98+ /* load_flags :: A set of bit flags similar to those used when */
99+ /* calling @FT_Load_Glyph, used to determine what kind */
100+ /* of advances you need. */
101+ /* <Output> */
102+ /* padvance :: The advance value. If scaling is performed (based on */
103+ /* the value of `load_flags'), the advance value is in */
104+ /* 16.16 format. Otherwise, it is in font units. */
105+ /* */
106+ /* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the */
107+ /* vertical advance corresponding to a vertical layout. */
108+ /* Otherwise, it is the horizontal advance in a */
109+ /* horizontal layout. */
110+ /* */
111+ /* <Return> */
112+ /* FreeType error code. 0 means success. */
113+ /* */
114+ /* <Note> */
115+ /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */
116+ /* if the corresponding font backend doesn't have a quick way to */
117+ /* retrieve the advances. */
118+ /* */
119+ /* A scaled advance is returned in 16.16 format but isn't transformed */
120+ /* by the affine transformation specified by @FT_Set_Transform. */
121+ /* */
122+ FT_EXPORT( FT_Error )
123+ FT_Get_Advance( FT_Face face,
124+ FT_UInt gindex,
125+ FT_Int32 load_flags,
126+ FT_Fixed *padvance );
127+
128+
129+ /*************************************************************************/
130+ /* */
131+ /* <Function> */
132+ /* FT_Get_Advances */
133+ /* */
134+ /* <Description> */
135+ /* Retrieve the advance values of several glyph outlines in an */
136+ /* @FT_Face. */
137+ /* */
138+ /* <Input> */
139+ /* face :: The source @FT_Face handle. */
140+ /* */
141+ /* start :: The first glyph index. */
142+ /* */
143+ /* count :: The number of advance values you want to retrieve. */
144+ /* */
145+ /* load_flags :: A set of bit flags similar to those used when */
146+ /* calling @FT_Load_Glyph. */
147+ /* */
148+ /* <Output> */
149+ /* padvance :: The advance values. This array, to be provided by the */
150+ /* caller, must contain at least `count' elements. */
151+ /* */
152+ /* If scaling is performed (based on the value of */
153+ /* `load_flags'), the advance values are in 16.16 format. */
154+ /* Otherwise, they are in font units. */
155+ /* */
156+ /* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the */
157+ /* vertical advances corresponding to a vertical layout. */
158+ /* Otherwise, they are the horizontal advances in a */
159+ /* horizontal layout. */
160+ /* */
161+ /* <Return> */
162+ /* FreeType error code. 0 means success. */
163+ /* */
164+ /* <Note> */
165+ /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */
166+ /* if the corresponding font backend doesn't have a quick way to */
167+ /* retrieve the advances. */
168+ /* */
169+ /* Scaled advances are returned in 16.16 format but aren't */
170+ /* transformed by the affine transformation specified by */
171+ /* @FT_Set_Transform. */
172+ /* */
173+ FT_EXPORT( FT_Error )
174+ FT_Get_Advances( FT_Face face,
175+ FT_UInt start,
176+ FT_UInt count,
177+ FT_Int32 load_flags,
178+ FT_Fixed *padvances );
179+
180+ /* */
181+
182+
183+FT_END_HEADER
184+
185+#endif /* FTADVANC_H_ */
186+
187+
188+/* END */
1@@ -0,0 +1,101 @@
2+/***************************************************************************/
3+/* */
4+/* ftbbox.h */
5+/* */
6+/* FreeType exact bbox computation (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+ /*************************************************************************/
21+ /* */
22+ /* This component has a _single_ role: to compute exact outline bounding */
23+ /* boxes. */
24+ /* */
25+ /* It is separated from the rest of the engine for various technical */
26+ /* reasons. It may well be integrated in `ftoutln' later. */
27+ /* */
28+ /*************************************************************************/
29+
30+
31+#ifndef FTBBOX_H_
32+#define FTBBOX_H_
33+
34+
35+#include <ft2build.h>
36+#include FT_FREETYPE_H
37+
38+#ifdef FREETYPE_H
39+#error "freetype.h of FreeType 1 has been loaded!"
40+#error "Please fix the directory search order for header files"
41+#error "so that freetype.h of FreeType 2 is found first."
42+#endif
43+
44+
45+FT_BEGIN_HEADER
46+
47+
48+ /*************************************************************************/
49+ /* */
50+ /* <Section> */
51+ /* outline_processing */
52+ /* */
53+ /*************************************************************************/
54+
55+
56+ /*************************************************************************/
57+ /* */
58+ /* <Function> */
59+ /* FT_Outline_Get_BBox */
60+ /* */
61+ /* <Description> */
62+ /* Compute the exact bounding box of an outline. This is slower */
63+ /* than computing the control box. However, it uses an advanced */
64+ /* algorithm that returns _very_ quickly when the two boxes */
65+ /* coincide. Otherwise, the outline Bezier arcs are traversed to */
66+ /* extract their extrema. */
67+ /* */
68+ /* <Input> */
69+ /* outline :: A pointer to the source outline. */
70+ /* */
71+ /* <Output> */
72+ /* abbox :: The outline's exact bounding box. */
73+ /* */
74+ /* <Return> */
75+ /* FreeType error code. 0~means success. */
76+ /* */
77+ /* <Note> */
78+ /* If the font is tricky and the glyph has been loaded with */
79+ /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */
80+ /* reasonable values for the BBox it is necessary to load the glyph */
81+ /* at a large ppem value (so that the hinting instructions can */
82+ /* properly shift and scale the subglyphs), then extracting the BBox, */
83+ /* which can be eventually converted back to font units. */
84+ /* */
85+ FT_EXPORT( FT_Error )
86+ FT_Outline_Get_BBox( FT_Outline* outline,
87+ FT_BBox *abbox );
88+
89+ /* */
90+
91+
92+FT_END_HEADER
93+
94+#endif /* FTBBOX_H_ */
95+
96+
97+/* END */
98+
99+
100+/* Local Variables: */
101+/* coding: utf-8 */
102+/* End: */
+210,
-0
1@@ -0,0 +1,210 @@
2+/***************************************************************************/
3+/* */
4+/* ftbdf.h */
5+/* */
6+/* FreeType API for accessing BDF-specific strings (specification). */
7+/* */
8+/* Copyright 2002-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTBDF_H_
21+#define FTBDF_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+
36+ /*************************************************************************/
37+ /* */
38+ /* <Section> */
39+ /* bdf_fonts */
40+ /* */
41+ /* <Title> */
42+ /* BDF and PCF Files */
43+ /* */
44+ /* <Abstract> */
45+ /* BDF and PCF specific API. */
46+ /* */
47+ /* <Description> */
48+ /* This section contains the declaration of functions specific to BDF */
49+ /* and PCF fonts. */
50+ /* */
51+ /*************************************************************************/
52+
53+
54+ /**********************************************************************
55+ *
56+ * @enum:
57+ * BDF_PropertyType
58+ *
59+ * @description:
60+ * A list of BDF property types.
61+ *
62+ * @values:
63+ * BDF_PROPERTY_TYPE_NONE ::
64+ * Value~0 is used to indicate a missing property.
65+ *
66+ * BDF_PROPERTY_TYPE_ATOM ::
67+ * Property is a string atom.
68+ *
69+ * BDF_PROPERTY_TYPE_INTEGER ::
70+ * Property is a 32-bit signed integer.
71+ *
72+ * BDF_PROPERTY_TYPE_CARDINAL ::
73+ * Property is a 32-bit unsigned integer.
74+ */
75+ typedef enum BDF_PropertyType_
76+ {
77+ BDF_PROPERTY_TYPE_NONE = 0,
78+ BDF_PROPERTY_TYPE_ATOM = 1,
79+ BDF_PROPERTY_TYPE_INTEGER = 2,
80+ BDF_PROPERTY_TYPE_CARDINAL = 3
81+
82+ } BDF_PropertyType;
83+
84+
85+ /**********************************************************************
86+ *
87+ * @type:
88+ * BDF_Property
89+ *
90+ * @description:
91+ * A handle to a @BDF_PropertyRec structure to model a given
92+ * BDF/PCF property.
93+ */
94+ typedef struct BDF_PropertyRec_* BDF_Property;
95+
96+
97+ /**********************************************************************
98+ *
99+ * @struct:
100+ * BDF_PropertyRec
101+ *
102+ * @description:
103+ * This structure models a given BDF/PCF property.
104+ *
105+ * @fields:
106+ * type ::
107+ * The property type.
108+ *
109+ * u.atom ::
110+ * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be
111+ * NULL, indicating an empty string.
112+ *
113+ * u.integer ::
114+ * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER.
115+ *
116+ * u.cardinal ::
117+ * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL.
118+ */
119+ typedef struct BDF_PropertyRec_
120+ {
121+ BDF_PropertyType type;
122+ union {
123+ const char* atom;
124+ FT_Int32 integer;
125+ FT_UInt32 cardinal;
126+
127+ } u;
128+
129+ } BDF_PropertyRec;
130+
131+
132+ /**********************************************************************
133+ *
134+ * @function:
135+ * FT_Get_BDF_Charset_ID
136+ *
137+ * @description:
138+ * Retrieve a BDF font character set identity, according to
139+ * the BDF specification.
140+ *
141+ * @input:
142+ * face ::
143+ * A handle to the input face.
144+ *
145+ * @output:
146+ * acharset_encoding ::
147+ * Charset encoding, as a C~string, owned by the face.
148+ *
149+ * acharset_registry ::
150+ * Charset registry, as a C~string, owned by the face.
151+ *
152+ * @return:
153+ * FreeType error code. 0~means success.
154+ *
155+ * @note:
156+ * This function only works with BDF faces, returning an error otherwise.
157+ */
158+ FT_EXPORT( FT_Error )
159+ FT_Get_BDF_Charset_ID( FT_Face face,
160+ const char* *acharset_encoding,
161+ const char* *acharset_registry );
162+
163+
164+ /**********************************************************************
165+ *
166+ * @function:
167+ * FT_Get_BDF_Property
168+ *
169+ * @description:
170+ * Retrieve a BDF property from a BDF or PCF font file.
171+ *
172+ * @input:
173+ * face :: A handle to the input face.
174+ *
175+ * name :: The property name.
176+ *
177+ * @output:
178+ * aproperty :: The property.
179+ *
180+ * @return:
181+ * FreeType error code. 0~means success.
182+ *
183+ * @note:
184+ * This function works with BDF _and_ PCF fonts. It returns an error
185+ * otherwise. It also returns an error if the property is not in the
186+ * font.
187+ *
188+ * A `property' is a either key-value pair within the STARTPROPERTIES
189+ * ... ENDPROPERTIES block of a BDF font or a key-value pair from the
190+ * `info->props' array within a `FontRec' structure of a PCF font.
191+ *
192+ * Integer properties are always stored as `signed' within PCF fonts;
193+ * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value
194+ * for BDF fonts only.
195+ *
196+ * In case of error, `aproperty->type' is always set to
197+ * @BDF_PROPERTY_TYPE_NONE.
198+ */
199+ FT_EXPORT( FT_Error )
200+ FT_Get_BDF_Property( FT_Face face,
201+ const char* prop_name,
202+ BDF_PropertyRec *aproperty );
203+
204+ /* */
205+
206+FT_END_HEADER
207+
208+#endif /* FTBDF_H_ */
209+
210+
211+/* END */
1@@ -0,0 +1,240 @@
2+/***************************************************************************/
3+/* */
4+/* ftbitmap.h */
5+/* */
6+/* FreeType utility functions for bitmaps (specification). */
7+/* */
8+/* Copyright 2004-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTBITMAP_H_
21+#define FTBITMAP_H_
22+
23+
24+#include <ft2build.h>
25+#include FT_FREETYPE_H
26+
27+#ifdef FREETYPE_H
28+#error "freetype.h of FreeType 1 has been loaded!"
29+#error "Please fix the directory search order for header files"
30+#error "so that freetype.h of FreeType 2 is found first."
31+#endif
32+
33+
34+FT_BEGIN_HEADER
35+
36+
37+ /*************************************************************************/
38+ /* */
39+ /* <Section> */
40+ /* bitmap_handling */
41+ /* */
42+ /* <Title> */
43+ /* Bitmap Handling */
44+ /* */
45+ /* <Abstract> */
46+ /* Handling FT_Bitmap objects. */
47+ /* */
48+ /* <Description> */
49+ /* This section contains functions for handling @FT_Bitmap objects. */
50+ /* Note that none of the functions changes the bitmap's `flow' (as */
51+ /* indicated by the sign of the `pitch' field in `FT_Bitmap'). */
52+ /* */
53+ /*************************************************************************/
54+
55+
56+ /*************************************************************************/
57+ /* */
58+ /* <Function> */
59+ /* FT_Bitmap_Init */
60+ /* */
61+ /* <Description> */
62+ /* Initialize a pointer to an @FT_Bitmap structure. */
63+ /* */
64+ /* <InOut> */
65+ /* abitmap :: A pointer to the bitmap structure. */
66+ /* */
67+ /* <Note> */
68+ /* A deprecated name for the same function is `FT_Bitmap_New'. */
69+ /* */
70+ FT_EXPORT( void )
71+ FT_Bitmap_Init( FT_Bitmap *abitmap );
72+
73+
74+ /* deprecated */
75+ FT_EXPORT( void )
76+ FT_Bitmap_New( FT_Bitmap *abitmap );
77+
78+
79+ /*************************************************************************/
80+ /* */
81+ /* <Function> */
82+ /* FT_Bitmap_Copy */
83+ /* */
84+ /* <Description> */
85+ /* Copy a bitmap into another one. */
86+ /* */
87+ /* <Input> */
88+ /* library :: A handle to a library object. */
89+ /* */
90+ /* source :: A handle to the source bitmap. */
91+ /* */
92+ /* <Output> */
93+ /* target :: A handle to the target bitmap. */
94+ /* */
95+ /* <Return> */
96+ /* FreeType error code. 0~means success. */
97+ /* */
98+ FT_EXPORT( FT_Error )
99+ FT_Bitmap_Copy( FT_Library library,
100+ const FT_Bitmap *source,
101+ FT_Bitmap *target );
102+
103+
104+ /*************************************************************************/
105+ /* */
106+ /* <Function> */
107+ /* FT_Bitmap_Embolden */
108+ /* */
109+ /* <Description> */
110+ /* Embolden a bitmap. The new bitmap will be about `xStrength' */
111+ /* pixels wider and `yStrength' pixels higher. The left and bottom */
112+ /* borders are kept unchanged. */
113+ /* */
114+ /* <Input> */
115+ /* library :: A handle to a library object. */
116+ /* */
117+ /* xStrength :: How strong the glyph is emboldened horizontally. */
118+ /* Expressed in 26.6 pixel format. */
119+ /* */
120+ /* yStrength :: How strong the glyph is emboldened vertically. */
121+ /* Expressed in 26.6 pixel format. */
122+ /* */
123+ /* <InOut> */
124+ /* bitmap :: A handle to the target bitmap. */
125+ /* */
126+ /* <Return> */
127+ /* FreeType error code. 0~means success. */
128+ /* */
129+ /* <Note> */
130+ /* The current implementation restricts `xStrength' to be less than */
131+ /* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */
132+ /* */
133+ /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */
134+ /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */
135+ /* */
136+ /* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */
137+ /* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */
138+ /* */
139+ FT_EXPORT( FT_Error )
140+ FT_Bitmap_Embolden( FT_Library library,
141+ FT_Bitmap* bitmap,
142+ FT_Pos xStrength,
143+ FT_Pos yStrength );
144+
145+
146+ /*************************************************************************/
147+ /* */
148+ /* <Function> */
149+ /* FT_Bitmap_Convert */
150+ /* */
151+ /* <Description> */
152+ /* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */
153+ /* to a bitmap object with depth 8bpp, making the number of used */
154+ /* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */
155+ /* */
156+ /* <Input> */
157+ /* library :: A handle to a library object. */
158+ /* */
159+ /* source :: The source bitmap. */
160+ /* */
161+ /* alignment :: The pitch of the bitmap is a multiple of this */
162+ /* parameter. Common values are 1, 2, or 4. */
163+ /* */
164+ /* <Output> */
165+ /* target :: The target bitmap. */
166+ /* */
167+ /* <Return> */
168+ /* FreeType error code. 0~means success. */
169+ /* */
170+ /* <Note> */
171+ /* It is possible to call @FT_Bitmap_Convert multiple times without */
172+ /* calling @FT_Bitmap_Done (the memory is simply reallocated). */
173+ /* */
174+ /* Use @FT_Bitmap_Done to finally remove the bitmap object. */
175+ /* */
176+ /* The `library' argument is taken to have access to FreeType's */
177+ /* memory handling functions. */
178+ /* */
179+ FT_EXPORT( FT_Error )
180+ FT_Bitmap_Convert( FT_Library library,
181+ const FT_Bitmap *source,
182+ FT_Bitmap *target,
183+ FT_Int alignment );
184+
185+
186+ /*************************************************************************/
187+ /* */
188+ /* <Function> */
189+ /* FT_GlyphSlot_Own_Bitmap */
190+ /* */
191+ /* <Description> */
192+ /* Make sure that a glyph slot owns `slot->bitmap'. */
193+ /* */
194+ /* <Input> */
195+ /* slot :: The glyph slot. */
196+ /* */
197+ /* <Return> */
198+ /* FreeType error code. 0~means success. */
199+ /* */
200+ /* <Note> */
201+ /* This function is to be used in combination with */
202+ /* @FT_Bitmap_Embolden. */
203+ /* */
204+ FT_EXPORT( FT_Error )
205+ FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
206+
207+
208+ /*************************************************************************/
209+ /* */
210+ /* <Function> */
211+ /* FT_Bitmap_Done */
212+ /* */
213+ /* <Description> */
214+ /* Destroy a bitmap object initialized with @FT_Bitmap_Init. */
215+ /* */
216+ /* <Input> */
217+ /* library :: A handle to a library object. */
218+ /* */
219+ /* bitmap :: The bitmap object to be freed. */
220+ /* */
221+ /* <Return> */
222+ /* FreeType error code. 0~means success. */
223+ /* */
224+ /* <Note> */
225+ /* The `library' argument is taken to have access to FreeType's */
226+ /* memory handling functions. */
227+ /* */
228+ FT_EXPORT( FT_Error )
229+ FT_Bitmap_Done( FT_Library library,
230+ FT_Bitmap *bitmap );
231+
232+
233+ /* */
234+
235+
236+FT_END_HEADER
237+
238+#endif /* FTBITMAP_H_ */
239+
240+
241+/* END */
1@@ -0,0 +1,102 @@
2+/***************************************************************************/
3+/* */
4+/* ftbzip2.h */
5+/* */
6+/* Bzip2-compressed stream support. */
7+/* */
8+/* Copyright 2010-2018 by */
9+/* Joel Klinghed. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTBZIP2_H_
21+#define FTBZIP2_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+ /*************************************************************************/
36+ /* */
37+ /* <Section> */
38+ /* bzip2 */
39+ /* */
40+ /* <Title> */
41+ /* BZIP2 Streams */
42+ /* */
43+ /* <Abstract> */
44+ /* Using bzip2-compressed font files. */
45+ /* */
46+ /* <Description> */
47+ /* This section contains the declaration of Bzip2-specific functions. */
48+ /* */
49+ /*************************************************************************/
50+
51+
52+ /************************************************************************
53+ *
54+ * @function:
55+ * FT_Stream_OpenBzip2
56+ *
57+ * @description:
58+ * Open a new stream to parse bzip2-compressed font files. This is
59+ * mainly used to support the compressed `*.pcf.bz2' fonts that come
60+ * with XFree86.
61+ *
62+ * @input:
63+ * stream ::
64+ * The target embedding stream.
65+ *
66+ * source ::
67+ * The source stream.
68+ *
69+ * @return:
70+ * FreeType error code. 0~means success.
71+ *
72+ * @note:
73+ * The source stream must be opened _before_ calling this function.
74+ *
75+ * Calling the internal function `FT_Stream_Close' on the new stream will
76+ * *not* call `FT_Stream_Close' on the source stream. None of the stream
77+ * objects will be released to the heap.
78+ *
79+ * The stream implementation is very basic and resets the decompression
80+ * process each time seeking backwards is needed within the stream.
81+ *
82+ * In certain builds of the library, bzip2 compression recognition is
83+ * automatically handled when calling @FT_New_Face or @FT_Open_Face.
84+ * This means that if no font driver is capable of handling the raw
85+ * compressed file, the library will try to open a bzip2 compressed stream
86+ * from it and re-open the face with it.
87+ *
88+ * This function may return `FT_Err_Unimplemented_Feature' if your build
89+ * of FreeType was not compiled with bzip2 support.
90+ */
91+ FT_EXPORT( FT_Error )
92+ FT_Stream_OpenBzip2( FT_Stream stream,
93+ FT_Stream source );
94+
95+ /* */
96+
97+
98+FT_END_HEADER
99+
100+#endif /* FTBZIP2_H_ */
101+
102+
103+/* END */
+1042,
-0
1@@ -0,0 +1,1042 @@
2+/***************************************************************************/
3+/* */
4+/* ftcache.h */
5+/* */
6+/* FreeType Cache subsystem (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTCACHE_H_
21+#define FTCACHE_H_
22+
23+
24+#include <ft2build.h>
25+#include FT_GLYPH_H
26+
27+
28+FT_BEGIN_HEADER
29+
30+
31+ /*************************************************************************
32+ *
33+ * <Section>
34+ * cache_subsystem
35+ *
36+ * <Title>
37+ * Cache Sub-System
38+ *
39+ * <Abstract>
40+ * How to cache face, size, and glyph data with FreeType~2.
41+ *
42+ * <Description>
43+ * This section describes the FreeType~2 cache sub-system, which is used
44+ * to limit the number of concurrently opened @FT_Face and @FT_Size
45+ * objects, as well as caching information like character maps and glyph
46+ * images while limiting their maximum memory usage.
47+ *
48+ * Note that all types and functions begin with the `FTC_' prefix.
49+ *
50+ * The cache is highly portable and thus doesn't know anything about the
51+ * fonts installed on your system, or how to access them. This implies
52+ * the following scheme:
53+ *
54+ * First, available or installed font faces are uniquely identified by
55+ * @FTC_FaceID values, provided to the cache by the client. Note that
56+ * the cache only stores and compares these values, and doesn't try to
57+ * interpret them in any way.
58+ *
59+ * Second, the cache calls, only when needed, a client-provided function
60+ * to convert an @FTC_FaceID into a new @FT_Face object. The latter is
61+ * then completely managed by the cache, including its termination
62+ * through @FT_Done_Face. To monitor termination of face objects, the
63+ * finalizer callback in the `generic' field of the @FT_Face object can
64+ * be used, which might also be used to store the @FTC_FaceID of the
65+ * face.
66+ *
67+ * Clients are free to map face IDs to anything else. The most simple
68+ * usage is to associate them to a (pathname,face_index) pair that is
69+ * used to call @FT_New_Face. However, more complex schemes are also
70+ * possible.
71+ *
72+ * Note that for the cache to work correctly, the face ID values must be
73+ * *persistent*, which means that the contents they point to should not
74+ * change at runtime, or that their value should not become invalid.
75+ *
76+ * If this is unavoidable (e.g., when a font is uninstalled at runtime),
77+ * you should call @FTC_Manager_RemoveFaceID as soon as possible, to let
78+ * the cache get rid of any references to the old @FTC_FaceID it may
79+ * keep internally. Failure to do so will lead to incorrect behaviour
80+ * or even crashes.
81+ *
82+ * To use the cache, start with calling @FTC_Manager_New to create a new
83+ * @FTC_Manager object, which models a single cache instance. You can
84+ * then look up @FT_Face and @FT_Size objects with
85+ * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively.
86+ *
87+ * If you want to use the charmap caching, call @FTC_CMapCache_New, then
88+ * later use @FTC_CMapCache_Lookup to perform the equivalent of
89+ * @FT_Get_Char_Index, only much faster.
90+ *
91+ * If you want to use the @FT_Glyph caching, call @FTC_ImageCache, then
92+ * later use @FTC_ImageCache_Lookup to retrieve the corresponding
93+ * @FT_Glyph objects from the cache.
94+ *
95+ * If you need lots of small bitmaps, it is much more memory efficient
96+ * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This
97+ * returns @FTC_SBitRec structures, which are used to store small
98+ * bitmaps directly. (A small bitmap is one whose metrics and
99+ * dimensions all fit into 8-bit integers).
100+ *
101+ * We hope to also provide a kerning cache in the near future.
102+ *
103+ *
104+ * <Order>
105+ * FTC_Manager
106+ * FTC_FaceID
107+ * FTC_Face_Requester
108+ *
109+ * FTC_Manager_New
110+ * FTC_Manager_Reset
111+ * FTC_Manager_Done
112+ * FTC_Manager_LookupFace
113+ * FTC_Manager_LookupSize
114+ * FTC_Manager_RemoveFaceID
115+ *
116+ * FTC_Node
117+ * FTC_Node_Unref
118+ *
119+ * FTC_ImageCache
120+ * FTC_ImageCache_New
121+ * FTC_ImageCache_Lookup
122+ *
123+ * FTC_SBit
124+ * FTC_SBitCache
125+ * FTC_SBitCache_New
126+ * FTC_SBitCache_Lookup
127+ *
128+ * FTC_CMapCache
129+ * FTC_CMapCache_New
130+ * FTC_CMapCache_Lookup
131+ *
132+ *************************************************************************/
133+
134+
135+ /*************************************************************************/
136+ /*************************************************************************/
137+ /*************************************************************************/
138+ /***** *****/
139+ /***** BASIC TYPE DEFINITIONS *****/
140+ /***** *****/
141+ /*************************************************************************/
142+ /*************************************************************************/
143+ /*************************************************************************/
144+
145+
146+ /*************************************************************************
147+ *
148+ * @type: FTC_FaceID
149+ *
150+ * @description:
151+ * An opaque pointer type that is used to identity face objects. The
152+ * contents of such objects is application-dependent.
153+ *
154+ * These pointers are typically used to point to a user-defined
155+ * structure containing a font file path, and face index.
156+ *
157+ * @note:
158+ * Never use NULL as a valid @FTC_FaceID.
159+ *
160+ * Face IDs are passed by the client to the cache manager that calls,
161+ * when needed, the @FTC_Face_Requester to translate them into new
162+ * @FT_Face objects.
163+ *
164+ * If the content of a given face ID changes at runtime, or if the value
165+ * becomes invalid (e.g., when uninstalling a font), you should
166+ * immediately call @FTC_Manager_RemoveFaceID before any other cache
167+ * function.
168+ *
169+ * Failure to do so will result in incorrect behaviour or even
170+ * memory leaks and crashes.
171+ */
172+ typedef FT_Pointer FTC_FaceID;
173+
174+
175+ /************************************************************************
176+ *
177+ * @functype:
178+ * FTC_Face_Requester
179+ *
180+ * @description:
181+ * A callback function provided by client applications. It is used by
182+ * the cache manager to translate a given @FTC_FaceID into a new valid
183+ * @FT_Face object, on demand.
184+ *
185+ * <Input>
186+ * face_id ::
187+ * The face ID to resolve.
188+ *
189+ * library ::
190+ * A handle to a FreeType library object.
191+ *
192+ * req_data ::
193+ * Application-provided request data (see note below).
194+ *
195+ * <Output>
196+ * aface ::
197+ * A new @FT_Face handle.
198+ *
199+ * <Return>
200+ * FreeType error code. 0~means success.
201+ *
202+ * <Note>
203+ * The third parameter `req_data' is the same as the one passed by the
204+ * client when @FTC_Manager_New is called.
205+ *
206+ * The face requester should not perform funny things on the returned
207+ * face object, like creating a new @FT_Size for it, or setting a
208+ * transformation through @FT_Set_Transform!
209+ */
210+ typedef FT_Error
211+ (*FTC_Face_Requester)( FTC_FaceID face_id,
212+ FT_Library library,
213+ FT_Pointer req_data,
214+ FT_Face* aface );
215+
216+ /* */
217+
218+
219+ /*************************************************************************/
220+ /*************************************************************************/
221+ /*************************************************************************/
222+ /***** *****/
223+ /***** CACHE MANAGER OBJECT *****/
224+ /***** *****/
225+ /*************************************************************************/
226+ /*************************************************************************/
227+ /*************************************************************************/
228+
229+
230+ /*************************************************************************/
231+ /* */
232+ /* <Type> */
233+ /* FTC_Manager */
234+ /* */
235+ /* <Description> */
236+ /* This object corresponds to one instance of the cache-subsystem. */
237+ /* It is used to cache one or more @FT_Face objects, along with */
238+ /* corresponding @FT_Size objects. */
239+ /* */
240+ /* The manager intentionally limits the total number of opened */
241+ /* @FT_Face and @FT_Size objects to control memory usage. See the */
242+ /* `max_faces' and `max_sizes' parameters of @FTC_Manager_New. */
243+ /* */
244+ /* The manager is also used to cache `nodes' of various types while */
245+ /* limiting their total memory usage. */
246+ /* */
247+ /* All limitations are enforced by keeping lists of managed objects */
248+ /* in most-recently-used order, and flushing old nodes to make room */
249+ /* for new ones. */
250+ /* */
251+ typedef struct FTC_ManagerRec_* FTC_Manager;
252+
253+
254+ /*************************************************************************/
255+ /* */
256+ /* <Type> */
257+ /* FTC_Node */
258+ /* */
259+ /* <Description> */
260+ /* An opaque handle to a cache node object. Each cache node is */
261+ /* reference-counted. A node with a count of~0 might be flushed */
262+ /* out of a full cache whenever a lookup request is performed. */
263+ /* */
264+ /* If you look up nodes, you have the ability to `acquire' them, */
265+ /* i.e., to increment their reference count. This will prevent the */
266+ /* node from being flushed out of the cache until you explicitly */
267+ /* `release' it (see @FTC_Node_Unref). */
268+ /* */
269+ /* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */
270+ /* */
271+ typedef struct FTC_NodeRec_* FTC_Node;
272+
273+
274+ /*************************************************************************/
275+ /* */
276+ /* <Function> */
277+ /* FTC_Manager_New */
278+ /* */
279+ /* <Description> */
280+ /* Create a new cache manager. */
281+ /* */
282+ /* <Input> */
283+ /* library :: The parent FreeType library handle to use. */
284+ /* */
285+ /* max_faces :: Maximum number of opened @FT_Face objects managed by */
286+ /* this cache instance. Use~0 for defaults. */
287+ /* */
288+ /* max_sizes :: Maximum number of opened @FT_Size objects managed by */
289+ /* this cache instance. Use~0 for defaults. */
290+ /* */
291+ /* max_bytes :: Maximum number of bytes to use for cached data nodes. */
292+ /* Use~0 for defaults. Note that this value does not */
293+ /* account for managed @FT_Face and @FT_Size objects. */
294+ /* */
295+ /* requester :: An application-provided callback used to translate */
296+ /* face IDs into real @FT_Face objects. */
297+ /* */
298+ /* req_data :: A generic pointer that is passed to the requester */
299+ /* each time it is called (see @FTC_Face_Requester). */
300+ /* */
301+ /* <Output> */
302+ /* amanager :: A handle to a new manager object. 0~in case of */
303+ /* failure. */
304+ /* */
305+ /* <Return> */
306+ /* FreeType error code. 0~means success. */
307+ /* */
308+ FT_EXPORT( FT_Error )
309+ FTC_Manager_New( FT_Library library,
310+ FT_UInt max_faces,
311+ FT_UInt max_sizes,
312+ FT_ULong max_bytes,
313+ FTC_Face_Requester requester,
314+ FT_Pointer req_data,
315+ FTC_Manager *amanager );
316+
317+
318+ /*************************************************************************/
319+ /* */
320+ /* <Function> */
321+ /* FTC_Manager_Reset */
322+ /* */
323+ /* <Description> */
324+ /* Empty a given cache manager. This simply gets rid of all the */
325+ /* currently cached @FT_Face and @FT_Size objects within the manager. */
326+ /* */
327+ /* <InOut> */
328+ /* manager :: A handle to the manager. */
329+ /* */
330+ FT_EXPORT( void )
331+ FTC_Manager_Reset( FTC_Manager manager );
332+
333+
334+ /*************************************************************************/
335+ /* */
336+ /* <Function> */
337+ /* FTC_Manager_Done */
338+ /* */
339+ /* <Description> */
340+ /* Destroy a given manager after emptying it. */
341+ /* */
342+ /* <Input> */
343+ /* manager :: A handle to the target cache manager object. */
344+ /* */
345+ FT_EXPORT( void )
346+ FTC_Manager_Done( FTC_Manager manager );
347+
348+
349+ /*************************************************************************/
350+ /* */
351+ /* <Function> */
352+ /* FTC_Manager_LookupFace */
353+ /* */
354+ /* <Description> */
355+ /* Retrieve the @FT_Face object that corresponds to a given face ID */
356+ /* through a cache manager. */
357+ /* */
358+ /* <Input> */
359+ /* manager :: A handle to the cache manager. */
360+ /* */
361+ /* face_id :: The ID of the face object. */
362+ /* */
363+ /* <Output> */
364+ /* aface :: A handle to the face object. */
365+ /* */
366+ /* <Return> */
367+ /* FreeType error code. 0~means success. */
368+ /* */
369+ /* <Note> */
370+ /* The returned @FT_Face object is always owned by the manager. You */
371+ /* should never try to discard it yourself. */
372+ /* */
373+ /* The @FT_Face object doesn't necessarily have a current size object */
374+ /* (i.e., face->size can be~0). If you need a specific `font size', */
375+ /* use @FTC_Manager_LookupSize instead. */
376+ /* */
377+ /* Never change the face's transformation matrix (i.e., never call */
378+ /* the @FT_Set_Transform function) on a returned face! If you need */
379+ /* to transform glyphs, do it yourself after glyph loading. */
380+ /* */
381+ /* When you perform a lookup, out-of-memory errors are detected */
382+ /* _within_ the lookup and force incremental flushes of the cache */
383+ /* until enough memory is released for the lookup to succeed. */
384+ /* */
385+ /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */
386+ /* already been completely flushed, and still no memory was available */
387+ /* for the operation. */
388+ /* */
389+ FT_EXPORT( FT_Error )
390+ FTC_Manager_LookupFace( FTC_Manager manager,
391+ FTC_FaceID face_id,
392+ FT_Face *aface );
393+
394+
395+ /*************************************************************************/
396+ /* */
397+ /* <Struct> */
398+ /* FTC_ScalerRec */
399+ /* */
400+ /* <Description> */
401+ /* A structure used to describe a given character size in either */
402+ /* pixels or points to the cache manager. See */
403+ /* @FTC_Manager_LookupSize. */
404+ /* */
405+ /* <Fields> */
406+ /* face_id :: The source face ID. */
407+ /* */
408+ /* width :: The character width. */
409+ /* */
410+ /* height :: The character height. */
411+ /* */
412+ /* pixel :: A Boolean. If 1, the `width' and `height' fields are */
413+ /* interpreted as integer pixel character sizes. */
414+ /* Otherwise, they are expressed as 1/64th of points. */
415+ /* */
416+ /* x_res :: Only used when `pixel' is value~0 to indicate the */
417+ /* horizontal resolution in dpi. */
418+ /* */
419+ /* y_res :: Only used when `pixel' is value~0 to indicate the */
420+ /* vertical resolution in dpi. */
421+ /* */
422+ /* <Note> */
423+ /* This type is mainly used to retrieve @FT_Size objects through the */
424+ /* cache manager. */
425+ /* */
426+ typedef struct FTC_ScalerRec_
427+ {
428+ FTC_FaceID face_id;
429+ FT_UInt width;
430+ FT_UInt height;
431+ FT_Int pixel;
432+ FT_UInt x_res;
433+ FT_UInt y_res;
434+
435+ } FTC_ScalerRec;
436+
437+
438+ /*************************************************************************/
439+ /* */
440+ /* <Struct> */
441+ /* FTC_Scaler */
442+ /* */
443+ /* <Description> */
444+ /* A handle to an @FTC_ScalerRec structure. */
445+ /* */
446+ typedef struct FTC_ScalerRec_* FTC_Scaler;
447+
448+
449+ /*************************************************************************/
450+ /* */
451+ /* <Function> */
452+ /* FTC_Manager_LookupSize */
453+ /* */
454+ /* <Description> */
455+ /* Retrieve the @FT_Size object that corresponds to a given */
456+ /* @FTC_ScalerRec pointer through a cache manager. */
457+ /* */
458+ /* <Input> */
459+ /* manager :: A handle to the cache manager. */
460+ /* */
461+ /* scaler :: A scaler handle. */
462+ /* */
463+ /* <Output> */
464+ /* asize :: A handle to the size object. */
465+ /* */
466+ /* <Return> */
467+ /* FreeType error code. 0~means success. */
468+ /* */
469+ /* <Note> */
470+ /* The returned @FT_Size object is always owned by the manager. You */
471+ /* should never try to discard it by yourself. */
472+ /* */
473+ /* You can access the parent @FT_Face object simply as `size->face' */
474+ /* if you need it. Note that this object is also owned by the */
475+ /* manager. */
476+ /* */
477+ /* <Note> */
478+ /* When you perform a lookup, out-of-memory errors are detected */
479+ /* _within_ the lookup and force incremental flushes of the cache */
480+ /* until enough memory is released for the lookup to succeed. */
481+ /* */
482+ /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */
483+ /* already been completely flushed, and still no memory is available */
484+ /* for the operation. */
485+ /* */
486+ FT_EXPORT( FT_Error )
487+ FTC_Manager_LookupSize( FTC_Manager manager,
488+ FTC_Scaler scaler,
489+ FT_Size *asize );
490+
491+
492+ /*************************************************************************/
493+ /* */
494+ /* <Function> */
495+ /* FTC_Node_Unref */
496+ /* */
497+ /* <Description> */
498+ /* Decrement a cache node's internal reference count. When the count */
499+ /* reaches 0, it is not destroyed but becomes eligible for subsequent */
500+ /* cache flushes. */
501+ /* */
502+ /* <Input> */
503+ /* node :: The cache node handle. */
504+ /* */
505+ /* manager :: The cache manager handle. */
506+ /* */
507+ FT_EXPORT( void )
508+ FTC_Node_Unref( FTC_Node node,
509+ FTC_Manager manager );
510+
511+
512+ /*************************************************************************
513+ *
514+ * @function:
515+ * FTC_Manager_RemoveFaceID
516+ *
517+ * @description:
518+ * A special function used to indicate to the cache manager that
519+ * a given @FTC_FaceID is no longer valid, either because its
520+ * content changed, or because it was deallocated or uninstalled.
521+ *
522+ * @input:
523+ * manager ::
524+ * The cache manager handle.
525+ *
526+ * face_id ::
527+ * The @FTC_FaceID to be removed.
528+ *
529+ * @note:
530+ * This function flushes all nodes from the cache corresponding to this
531+ * `face_id', with the exception of nodes with a non-null reference
532+ * count.
533+ *
534+ * Such nodes are however modified internally so as to never appear
535+ * in later lookups with the same `face_id' value, and to be immediately
536+ * destroyed when released by all their users.
537+ *
538+ */
539+ FT_EXPORT( void )
540+ FTC_Manager_RemoveFaceID( FTC_Manager manager,
541+ FTC_FaceID face_id );
542+
543+
544+ /*************************************************************************
545+ *
546+ * @type:
547+ * FTC_CMapCache
548+ *
549+ * @description:
550+ * An opaque handle used to model a charmap cache. This cache is to
551+ * hold character codes -> glyph indices mappings.
552+ *
553+ */
554+ typedef struct FTC_CMapCacheRec_* FTC_CMapCache;
555+
556+
557+ /*************************************************************************
558+ *
559+ * @function:
560+ * FTC_CMapCache_New
561+ *
562+ * @description:
563+ * Create a new charmap cache.
564+ *
565+ * @input:
566+ * manager ::
567+ * A handle to the cache manager.
568+ *
569+ * @output:
570+ * acache ::
571+ * A new cache handle. NULL in case of error.
572+ *
573+ * @return:
574+ * FreeType error code. 0~means success.
575+ *
576+ * @note:
577+ * Like all other caches, this one will be destroyed with the cache
578+ * manager.
579+ *
580+ */
581+ FT_EXPORT( FT_Error )
582+ FTC_CMapCache_New( FTC_Manager manager,
583+ FTC_CMapCache *acache );
584+
585+
586+ /************************************************************************
587+ *
588+ * @function:
589+ * FTC_CMapCache_Lookup
590+ *
591+ * @description:
592+ * Translate a character code into a glyph index, using the charmap
593+ * cache.
594+ *
595+ * @input:
596+ * cache ::
597+ * A charmap cache handle.
598+ *
599+ * face_id ::
600+ * The source face ID.
601+ *
602+ * cmap_index ::
603+ * The index of the charmap in the source face. Any negative value
604+ * means to use the cache @FT_Face's default charmap.
605+ *
606+ * char_code ::
607+ * The character code (in the corresponding charmap).
608+ *
609+ * @return:
610+ * Glyph index. 0~means `no glyph'.
611+ *
612+ */
613+ FT_EXPORT( FT_UInt )
614+ FTC_CMapCache_Lookup( FTC_CMapCache cache,
615+ FTC_FaceID face_id,
616+ FT_Int cmap_index,
617+ FT_UInt32 char_code );
618+
619+
620+ /*************************************************************************/
621+ /*************************************************************************/
622+ /*************************************************************************/
623+ /***** *****/
624+ /***** IMAGE CACHE OBJECT *****/
625+ /***** *****/
626+ /*************************************************************************/
627+ /*************************************************************************/
628+ /*************************************************************************/
629+
630+
631+ /*************************************************************************
632+ *
633+ * @struct:
634+ * FTC_ImageTypeRec
635+ *
636+ * @description:
637+ * A structure used to model the type of images in a glyph cache.
638+ *
639+ * @fields:
640+ * face_id ::
641+ * The face ID.
642+ *
643+ * width ::
644+ * The width in pixels.
645+ *
646+ * height ::
647+ * The height in pixels.
648+ *
649+ * flags ::
650+ * The load flags, as in @FT_Load_Glyph.
651+ *
652+ */
653+ typedef struct FTC_ImageTypeRec_
654+ {
655+ FTC_FaceID face_id;
656+ FT_UInt width;
657+ FT_UInt height;
658+ FT_Int32 flags;
659+
660+ } FTC_ImageTypeRec;
661+
662+
663+ /*************************************************************************
664+ *
665+ * @type:
666+ * FTC_ImageType
667+ *
668+ * @description:
669+ * A handle to an @FTC_ImageTypeRec structure.
670+ *
671+ */
672+ typedef struct FTC_ImageTypeRec_* FTC_ImageType;
673+
674+
675+ /* */
676+
677+
678+#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \
679+ ( (d1)->face_id == (d2)->face_id && \
680+ (d1)->width == (d2)->width && \
681+ (d1)->flags == (d2)->flags )
682+
683+
684+ /*************************************************************************/
685+ /* */
686+ /* <Type> */
687+ /* FTC_ImageCache */
688+ /* */
689+ /* <Description> */
690+ /* A handle to a glyph image cache object. They are designed to */
691+ /* hold many distinct glyph images while not exceeding a certain */
692+ /* memory threshold. */
693+ /* */
694+ typedef struct FTC_ImageCacheRec_* FTC_ImageCache;
695+
696+
697+ /*************************************************************************/
698+ /* */
699+ /* <Function> */
700+ /* FTC_ImageCache_New */
701+ /* */
702+ /* <Description> */
703+ /* Create a new glyph image cache. */
704+ /* */
705+ /* <Input> */
706+ /* manager :: The parent manager for the image cache. */
707+ /* */
708+ /* <Output> */
709+ /* acache :: A handle to the new glyph image cache object. */
710+ /* */
711+ /* <Return> */
712+ /* FreeType error code. 0~means success. */
713+ /* */
714+ FT_EXPORT( FT_Error )
715+ FTC_ImageCache_New( FTC_Manager manager,
716+ FTC_ImageCache *acache );
717+
718+
719+ /*************************************************************************/
720+ /* */
721+ /* <Function> */
722+ /* FTC_ImageCache_Lookup */
723+ /* */
724+ /* <Description> */
725+ /* Retrieve a given glyph image from a glyph image cache. */
726+ /* */
727+ /* <Input> */
728+ /* cache :: A handle to the source glyph image cache. */
729+ /* */
730+ /* type :: A pointer to a glyph image type descriptor. */
731+ /* */
732+ /* gindex :: The glyph index to retrieve. */
733+ /* */
734+ /* <Output> */
735+ /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */
736+ /* failure. */
737+ /* */
738+ /* anode :: Used to return the address of the corresponding cache */
739+ /* node after incrementing its reference count (see note */
740+ /* below). */
741+ /* */
742+ /* <Return> */
743+ /* FreeType error code. 0~means success. */
744+ /* */
745+ /* <Note> */
746+ /* The returned glyph is owned and managed by the glyph image cache. */
747+ /* Never try to transform or discard it manually! You can however */
748+ /* create a copy with @FT_Glyph_Copy and modify the new one. */
749+ /* */
750+ /* If `anode' is _not_ NULL, it receives the address of the cache */
751+ /* node containing the glyph image, after increasing its reference */
752+ /* count. This ensures that the node (as well as the @FT_Glyph) will */
753+ /* always be kept in the cache until you call @FTC_Node_Unref to */
754+ /* `release' it. */
755+ /* */
756+ /* If `anode' is NULL, the cache node is left unchanged, which means */
757+ /* that the @FT_Glyph could be flushed out of the cache on the next */
758+ /* call to one of the caching sub-system APIs. Don't assume that it */
759+ /* is persistent! */
760+ /* */
761+ FT_EXPORT( FT_Error )
762+ FTC_ImageCache_Lookup( FTC_ImageCache cache,
763+ FTC_ImageType type,
764+ FT_UInt gindex,
765+ FT_Glyph *aglyph,
766+ FTC_Node *anode );
767+
768+
769+ /*************************************************************************/
770+ /* */
771+ /* <Function> */
772+ /* FTC_ImageCache_LookupScaler */
773+ /* */
774+ /* <Description> */
775+ /* A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec */
776+ /* to specify the face ID and its size. */
777+ /* */
778+ /* <Input> */
779+ /* cache :: A handle to the source glyph image cache. */
780+ /* */
781+ /* scaler :: A pointer to a scaler descriptor. */
782+ /* */
783+ /* load_flags :: The corresponding load flags. */
784+ /* */
785+ /* gindex :: The glyph index to retrieve. */
786+ /* */
787+ /* <Output> */
788+ /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */
789+ /* failure. */
790+ /* */
791+ /* anode :: Used to return the address of the corresponding */
792+ /* cache node after incrementing its reference count */
793+ /* (see note below). */
794+ /* */
795+ /* <Return> */
796+ /* FreeType error code. 0~means success. */
797+ /* */
798+ /* <Note> */
799+ /* The returned glyph is owned and managed by the glyph image cache. */
800+ /* Never try to transform or discard it manually! You can however */
801+ /* create a copy with @FT_Glyph_Copy and modify the new one. */
802+ /* */
803+ /* If `anode' is _not_ NULL, it receives the address of the cache */
804+ /* node containing the glyph image, after increasing its reference */
805+ /* count. This ensures that the node (as well as the @FT_Glyph) will */
806+ /* always be kept in the cache until you call @FTC_Node_Unref to */
807+ /* `release' it. */
808+ /* */
809+ /* If `anode' is NULL, the cache node is left unchanged, which means */
810+ /* that the @FT_Glyph could be flushed out of the cache on the next */
811+ /* call to one of the caching sub-system APIs. Don't assume that it */
812+ /* is persistent! */
813+ /* */
814+ /* Calls to @FT_Set_Char_Size and friends have no effect on cached */
815+ /* glyphs; you should always use the FreeType cache API instead. */
816+ /* */
817+ FT_EXPORT( FT_Error )
818+ FTC_ImageCache_LookupScaler( FTC_ImageCache cache,
819+ FTC_Scaler scaler,
820+ FT_ULong load_flags,
821+ FT_UInt gindex,
822+ FT_Glyph *aglyph,
823+ FTC_Node *anode );
824+
825+
826+ /*************************************************************************/
827+ /* */
828+ /* <Type> */
829+ /* FTC_SBit */
830+ /* */
831+ /* <Description> */
832+ /* A handle to a small bitmap descriptor. See the @FTC_SBitRec */
833+ /* structure for details. */
834+ /* */
835+ typedef struct FTC_SBitRec_* FTC_SBit;
836+
837+
838+ /*************************************************************************/
839+ /* */
840+ /* <Struct> */
841+ /* FTC_SBitRec */
842+ /* */
843+ /* <Description> */
844+ /* A very compact structure used to describe a small glyph bitmap. */
845+ /* */
846+ /* <Fields> */
847+ /* width :: The bitmap width in pixels. */
848+ /* */
849+ /* height :: The bitmap height in pixels. */
850+ /* */
851+ /* left :: The horizontal distance from the pen position to the */
852+ /* left bitmap border (a.k.a. `left side bearing', or */
853+ /* `lsb'). */
854+ /* */
855+ /* top :: The vertical distance from the pen position (on the */
856+ /* baseline) to the upper bitmap border (a.k.a. `top */
857+ /* side bearing'). The distance is positive for upwards */
858+ /* y~coordinates. */
859+ /* */
860+ /* format :: The format of the glyph bitmap (monochrome or gray). */
861+ /* */
862+ /* max_grays :: Maximum gray level value (in the range 1 to~255). */
863+ /* */
864+ /* pitch :: The number of bytes per bitmap line. May be positive */
865+ /* or negative. */
866+ /* */
867+ /* xadvance :: The horizontal advance width in pixels. */
868+ /* */
869+ /* yadvance :: The vertical advance height in pixels. */
870+ /* */
871+ /* buffer :: A pointer to the bitmap pixels. */
872+ /* */
873+ typedef struct FTC_SBitRec_
874+ {
875+ FT_Byte width;
876+ FT_Byte height;
877+ FT_Char left;
878+ FT_Char top;
879+
880+ FT_Byte format;
881+ FT_Byte max_grays;
882+ FT_Short pitch;
883+ FT_Char xadvance;
884+ FT_Char yadvance;
885+
886+ FT_Byte* buffer;
887+
888+ } FTC_SBitRec;
889+
890+
891+ /*************************************************************************/
892+ /* */
893+ /* <Type> */
894+ /* FTC_SBitCache */
895+ /* */
896+ /* <Description> */
897+ /* A handle to a small bitmap cache. These are special cache objects */
898+ /* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */
899+ /* much more efficient way than the traditional glyph image cache */
900+ /* implemented by @FTC_ImageCache. */
901+ /* */
902+ typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
903+
904+
905+ /*************************************************************************/
906+ /* */
907+ /* <Function> */
908+ /* FTC_SBitCache_New */
909+ /* */
910+ /* <Description> */
911+ /* Create a new cache to store small glyph bitmaps. */
912+ /* */
913+ /* <Input> */
914+ /* manager :: A handle to the source cache manager. */
915+ /* */
916+ /* <Output> */
917+ /* acache :: A handle to the new sbit cache. NULL in case of error. */
918+ /* */
919+ /* <Return> */
920+ /* FreeType error code. 0~means success. */
921+ /* */
922+ FT_EXPORT( FT_Error )
923+ FTC_SBitCache_New( FTC_Manager manager,
924+ FTC_SBitCache *acache );
925+
926+
927+ /*************************************************************************/
928+ /* */
929+ /* <Function> */
930+ /* FTC_SBitCache_Lookup */
931+ /* */
932+ /* <Description> */
933+ /* Look up a given small glyph bitmap in a given sbit cache and */
934+ /* `lock' it to prevent its flushing from the cache until needed. */
935+ /* */
936+ /* <Input> */
937+ /* cache :: A handle to the source sbit cache. */
938+ /* */
939+ /* type :: A pointer to the glyph image type descriptor. */
940+ /* */
941+ /* gindex :: The glyph index. */
942+ /* */
943+ /* <Output> */
944+ /* sbit :: A handle to a small bitmap descriptor. */
945+ /* */
946+ /* anode :: Used to return the address of the corresponding cache */
947+ /* node after incrementing its reference count (see note */
948+ /* below). */
949+ /* */
950+ /* <Return> */
951+ /* FreeType error code. 0~means success. */
952+ /* */
953+ /* <Note> */
954+ /* The small bitmap descriptor and its bit buffer are owned by the */
955+ /* cache and should never be freed by the application. They might */
956+ /* as well disappear from memory on the next cache lookup, so don't */
957+ /* treat them as persistent data. */
958+ /* */
959+ /* The descriptor's `buffer' field is set to~0 to indicate a missing */
960+ /* glyph bitmap. */
961+ /* */
962+ /* If `anode' is _not_ NULL, it receives the address of the cache */
963+ /* node containing the bitmap, after increasing its reference count. */
964+ /* This ensures that the node (as well as the image) will always be */
965+ /* kept in the cache until you call @FTC_Node_Unref to `release' it. */
966+ /* */
967+ /* If `anode' is NULL, the cache node is left unchanged, which means */
968+ /* that the bitmap could be flushed out of the cache on the next */
969+ /* call to one of the caching sub-system APIs. Don't assume that it */
970+ /* is persistent! */
971+ /* */
972+ FT_EXPORT( FT_Error )
973+ FTC_SBitCache_Lookup( FTC_SBitCache cache,
974+ FTC_ImageType type,
975+ FT_UInt gindex,
976+ FTC_SBit *sbit,
977+ FTC_Node *anode );
978+
979+
980+ /*************************************************************************/
981+ /* */
982+ /* <Function> */
983+ /* FTC_SBitCache_LookupScaler */
984+ /* */
985+ /* <Description> */
986+ /* A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec */
987+ /* to specify the face ID and its size. */
988+ /* */
989+ /* <Input> */
990+ /* cache :: A handle to the source sbit cache. */
991+ /* */
992+ /* scaler :: A pointer to the scaler descriptor. */
993+ /* */
994+ /* load_flags :: The corresponding load flags. */
995+ /* */
996+ /* gindex :: The glyph index. */
997+ /* */
998+ /* <Output> */
999+ /* sbit :: A handle to a small bitmap descriptor. */
1000+ /* */
1001+ /* anode :: Used to return the address of the corresponding */
1002+ /* cache node after incrementing its reference count */
1003+ /* (see note below). */
1004+ /* */
1005+ /* <Return> */
1006+ /* FreeType error code. 0~means success. */
1007+ /* */
1008+ /* <Note> */
1009+ /* The small bitmap descriptor and its bit buffer are owned by the */
1010+ /* cache and should never be freed by the application. They might */
1011+ /* as well disappear from memory on the next cache lookup, so don't */
1012+ /* treat them as persistent data. */
1013+ /* */
1014+ /* The descriptor's `buffer' field is set to~0 to indicate a missing */
1015+ /* glyph bitmap. */
1016+ /* */
1017+ /* If `anode' is _not_ NULL, it receives the address of the cache */
1018+ /* node containing the bitmap, after increasing its reference count. */
1019+ /* This ensures that the node (as well as the image) will always be */
1020+ /* kept in the cache until you call @FTC_Node_Unref to `release' it. */
1021+ /* */
1022+ /* If `anode' is NULL, the cache node is left unchanged, which means */
1023+ /* that the bitmap could be flushed out of the cache on the next */
1024+ /* call to one of the caching sub-system APIs. Don't assume that it */
1025+ /* is persistent! */
1026+ /* */
1027+ FT_EXPORT( FT_Error )
1028+ FTC_SBitCache_LookupScaler( FTC_SBitCache cache,
1029+ FTC_Scaler scaler,
1030+ FT_ULong load_flags,
1031+ FT_UInt gindex,
1032+ FTC_SBit *sbit,
1033+ FTC_Node *anode );
1034+
1035+ /* */
1036+
1037+
1038+FT_END_HEADER
1039+
1040+#endif /* FTCACHE_H_ */
1041+
1042+
1043+/* END */
1@@ -0,0 +1,139 @@
2+/***************************************************************************/
3+/* */
4+/* This file defines the structure of the FreeType reference. */
5+/* It is used by the python script that generates the HTML files. */
6+/* */
7+/***************************************************************************/
8+
9+
10+/***************************************************************************/
11+/* */
12+/* <Chapter> */
13+/* general_remarks */
14+/* */
15+/* <Title> */
16+/* General Remarks */
17+/* */
18+/* <Sections> */
19+/* header_inclusion */
20+/* user_allocation */
21+/* */
22+/***************************************************************************/
23+
24+
25+/***************************************************************************/
26+/* */
27+/* <Chapter> */
28+/* core_api */
29+/* */
30+/* <Title> */
31+/* Core API */
32+/* */
33+/* <Sections> */
34+/* version */
35+/* basic_types */
36+/* base_interface */
37+/* glyph_variants */
38+/* glyph_management */
39+/* mac_specific */
40+/* sizes_management */
41+/* header_file_macros */
42+/* */
43+/***************************************************************************/
44+
45+
46+/***************************************************************************/
47+/* */
48+/* <Chapter> */
49+/* format_specific */
50+/* */
51+/* <Title> */
52+/* Format-Specific API */
53+/* */
54+/* <Sections> */
55+/* multiple_masters */
56+/* truetype_tables */
57+/* type1_tables */
58+/* sfnt_names */
59+/* bdf_fonts */
60+/* cid_fonts */
61+/* pfr_fonts */
62+/* winfnt_fonts */
63+/* font_formats */
64+/* gasp_table */
65+/* */
66+/***************************************************************************/
67+
68+
69+/***************************************************************************/
70+/* */
71+/* <Chapter> */
72+/* module_specific */
73+/* */
74+/* <Title> */
75+/* Controlling FreeType Modules */
76+/* */
77+/* <Sections> */
78+/* auto_hinter */
79+/* cff_driver */
80+/* t1_cid_driver */
81+/* tt_driver */
82+/* pcf_driver */
83+/* properties */
84+/* parameter_tags */
85+/* */
86+/***************************************************************************/
87+
88+
89+/***************************************************************************/
90+/* */
91+/* <Chapter> */
92+/* cache_subsystem */
93+/* */
94+/* <Title> */
95+/* Cache Sub-System */
96+/* */
97+/* <Sections> */
98+/* cache_subsystem */
99+/* */
100+/***************************************************************************/
101+
102+
103+/***************************************************************************/
104+/* */
105+/* <Chapter> */
106+/* support_api */
107+/* */
108+/* <Title> */
109+/* Support API */
110+/* */
111+/* <Sections> */
112+/* computations */
113+/* list_processing */
114+/* outline_processing */
115+/* quick_advance */
116+/* bitmap_handling */
117+/* raster */
118+/* glyph_stroker */
119+/* system_interface */
120+/* module_management */
121+/* gzip */
122+/* lzw */
123+/* bzip2 */
124+/* lcd_filtering */
125+/* */
126+/***************************************************************************/
127+
128+/***************************************************************************/
129+/* */
130+/* <Chapter> */
131+/* error_codes */
132+/* */
133+/* <Title> */
134+/* Error Codes */
135+/* */
136+/* <Sections> */
137+/* error_enumerations */
138+/* error_code_values */
139+/* */
140+/***************************************************************************/
+168,
-0
1@@ -0,0 +1,168 @@
2+/***************************************************************************/
3+/* */
4+/* ftcid.h */
5+/* */
6+/* FreeType API for accessing CID font information (specification). */
7+/* */
8+/* Copyright 2007-2018 by */
9+/* Dereg Clegg and Michael Toftdal. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTCID_H_
21+#define FTCID_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+
36+ /*************************************************************************/
37+ /* */
38+ /* <Section> */
39+ /* cid_fonts */
40+ /* */
41+ /* <Title> */
42+ /* CID Fonts */
43+ /* */
44+ /* <Abstract> */
45+ /* CID-keyed font specific API. */
46+ /* */
47+ /* <Description> */
48+ /* This section contains the declaration of CID-keyed font specific */
49+ /* functions. */
50+ /* */
51+ /*************************************************************************/
52+
53+
54+ /**********************************************************************
55+ *
56+ * @function:
57+ * FT_Get_CID_Registry_Ordering_Supplement
58+ *
59+ * @description:
60+ * Retrieve the Registry/Ordering/Supplement triple (also known as the
61+ * "R/O/S") from a CID-keyed font.
62+ *
63+ * @input:
64+ * face ::
65+ * A handle to the input face.
66+ *
67+ * @output:
68+ * registry ::
69+ * The registry, as a C~string, owned by the face.
70+ *
71+ * ordering ::
72+ * The ordering, as a C~string, owned by the face.
73+ *
74+ * supplement ::
75+ * The supplement.
76+ *
77+ * @return:
78+ * FreeType error code. 0~means success.
79+ *
80+ * @note:
81+ * This function only works with CID faces, returning an error
82+ * otherwise.
83+ *
84+ * @since:
85+ * 2.3.6
86+ */
87+ FT_EXPORT( FT_Error )
88+ FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
89+ const char* *registry,
90+ const char* *ordering,
91+ FT_Int *supplement );
92+
93+
94+ /**********************************************************************
95+ *
96+ * @function:
97+ * FT_Get_CID_Is_Internally_CID_Keyed
98+ *
99+ * @description:
100+ * Retrieve the type of the input face, CID keyed or not. In
101+ * contrast to the @FT_IS_CID_KEYED macro this function returns
102+ * successfully also for CID-keyed fonts in an SFNT wrapper.
103+ *
104+ * @input:
105+ * face ::
106+ * A handle to the input face.
107+ *
108+ * @output:
109+ * is_cid ::
110+ * The type of the face as an @FT_Bool.
111+ *
112+ * @return:
113+ * FreeType error code. 0~means success.
114+ *
115+ * @note:
116+ * This function only works with CID faces and OpenType fonts,
117+ * returning an error otherwise.
118+ *
119+ * @since:
120+ * 2.3.9
121+ */
122+ FT_EXPORT( FT_Error )
123+ FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
124+ FT_Bool *is_cid );
125+
126+
127+ /**********************************************************************
128+ *
129+ * @function:
130+ * FT_Get_CID_From_Glyph_Index
131+ *
132+ * @description:
133+ * Retrieve the CID of the input glyph index.
134+ *
135+ * @input:
136+ * face ::
137+ * A handle to the input face.
138+ *
139+ * glyph_index ::
140+ * The input glyph index.
141+ *
142+ * @output:
143+ * cid ::
144+ * The CID as an @FT_UInt.
145+ *
146+ * @return:
147+ * FreeType error code. 0~means success.
148+ *
149+ * @note:
150+ * This function only works with CID faces and OpenType fonts,
151+ * returning an error otherwise.
152+ *
153+ * @since:
154+ * 2.3.9
155+ */
156+ FT_EXPORT( FT_Error )
157+ FT_Get_CID_From_Glyph_Index( FT_Face face,
158+ FT_UInt glyph_index,
159+ FT_UInt *cid );
160+
161+ /* */
162+
163+
164+FT_END_HEADER
165+
166+#endif /* FTCID_H_ */
167+
168+
169+/* END */
+1225,
-0
1@@ -0,0 +1,1225 @@
2+/***************************************************************************/
3+/* */
4+/* ftdriver.h */
5+/* */
6+/* FreeType API for controlling driver modules (specification only). */
7+/* */
8+/* Copyright 2017-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTDRIVER_H_
21+#define FTDRIVER_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+#include FT_PARAMETER_TAGS_H
26+
27+#ifdef FREETYPE_H
28+#error "freetype.h of FreeType 1 has been loaded!"
29+#error "Please fix the directory search order for header files"
30+#error "so that freetype.h of FreeType 2 is found first."
31+#endif
32+
33+
34+FT_BEGIN_HEADER
35+
36+
37+ /**************************************************************************
38+ *
39+ * @section:
40+ * auto_hinter
41+ *
42+ * @title:
43+ * The auto-hinter
44+ *
45+ * @abstract:
46+ * Controlling the auto-hinting module.
47+ *
48+ * @description:
49+ * While FreeType's auto-hinter doesn't expose API functions by itself,
50+ * it is possible to control its behaviour with @FT_Property_Set and
51+ * @FT_Property_Get. The following lists the available properties
52+ * together with the necessary macros and structures.
53+ *
54+ * Note that the auto-hinter's module name is `autofitter' for
55+ * historical reasons.
56+ *
57+ * Available properties are @increase-x-height, @no-stem-darkening
58+ * (experimental), @darkening-parameters (experimental), @warping
59+ * (experimental), @glyph-to-script-map (experimental), @fallback-script
60+ * (experimental), and @default-script (experimental), as documented in
61+ * the @properties section.
62+ *
63+ */
64+
65+
66+ /**************************************************************************
67+ *
68+ * @section:
69+ * cff_driver
70+ *
71+ * @title:
72+ * The CFF driver
73+ *
74+ * @abstract:
75+ * Controlling the CFF driver module.
76+ *
77+ * @description:
78+ * While FreeType's CFF driver doesn't expose API functions by itself,
79+ * it is possible to control its behaviour with @FT_Property_Set and
80+ * @FT_Property_Get.
81+ *
82+ * The CFF driver's module name is `cff'.
83+ *
84+ * Available properties are @hinting-engine, @no-stem-darkening,
85+ * @darkening-parameters, and @random-seed, as documented in the
86+ * @properties section.
87+ *
88+ *
89+ * *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine*
90+ *
91+ * The rasterizer is positioning horizontal features (e.g., ascender
92+ * height & x-height, or crossbars) on the pixel grid and minimizing the
93+ * amount of antialiasing applied to them, while placing vertical
94+ * features (vertical stems) on the pixel grid without hinting, thus
95+ * representing the stem position and weight accurately. Sometimes the
96+ * vertical stems may be only partially black. In this context,
97+ * `antialiasing' means that stems are not positioned exactly on pixel
98+ * borders, causing a fuzzy appearance.
99+ *
100+ * There are two principles behind this approach.
101+ *
102+ * 1) No hinting in the horizontal direction: Unlike `superhinted'
103+ * TrueType, which changes glyph widths to accommodate regular
104+ * inter-glyph spacing, Adobe's approach is `faithful to the design' in
105+ * representing both the glyph width and the inter-glyph spacing
106+ * designed for the font. This makes the screen display as close as it
107+ * can be to the result one would get with infinite resolution, while
108+ * preserving what is considered the key characteristics of each glyph.
109+ * Note that the distances between unhinted and grid-fitted positions at
110+ * small sizes are comparable to kerning values and thus would be
111+ * noticeable (and distracting) while reading if hinting were applied.
112+ *
113+ * One of the reasons to not hint horizontally is antialiasing for LCD
114+ * screens: The pixel geometry of modern displays supplies three
115+ * vertical subpixels as the eye moves horizontally across each visible
116+ * pixel. On devices where we can be certain this characteristic is
117+ * present a rasterizer can take advantage of the subpixels to add
118+ * increments of weight. In Western writing systems this turns out to
119+ * be the more critical direction anyway; the weights and spacing of
120+ * vertical stems (see above) are central to Armenian, Cyrillic, Greek,
121+ * and Latin type designs. Even when the rasterizer uses greyscale
122+ * antialiasing instead of color (a necessary compromise when one
123+ * doesn't know the screen characteristics), the unhinted vertical
124+ * features preserve the design's weight and spacing much better than
125+ * aliased type would.
126+ *
127+ * 2) Alignment in the vertical direction: Weights and spacing along the
128+ * y~axis are less critical; what is much more important is the visual
129+ * alignment of related features (like cap-height and x-height). The
130+ * sense of alignment for these is enhanced by the sharpness of grid-fit
131+ * edges, while the cruder vertical resolution (full pixels instead of
132+ * 1/3 pixels) is less of a problem.
133+ *
134+ * On the technical side, horizontal alignment zones for ascender,
135+ * x-height, and other important height values (traditionally called
136+ * `blue zones') as defined in the font are positioned independently,
137+ * each being rounded to the nearest pixel edge, taking care of
138+ * overshoot suppression at small sizes, stem darkening, and scaling.
139+ *
140+ * Hstems (this is, hint values defined in the font to help align
141+ * horizontal features) that fall within a blue zone are said to be
142+ * `captured' and are aligned to that zone. Uncaptured stems are moved
143+ * in one of four ways, top edge up or down, bottom edge up or down.
144+ * Unless there are conflicting hstems, the smallest movement is taken
145+ * to minimize distortion.
146+ *
147+ */
148+
149+
150+ /**************************************************************************
151+ *
152+ * @section:
153+ * pcf_driver
154+ *
155+ * @title:
156+ * The PCF driver
157+ *
158+ * @abstract:
159+ * Controlling the PCF driver module.
160+ *
161+ * @description:
162+ * While FreeType's PCF driver doesn't expose API functions by itself,
163+ * it is possible to control its behaviour with @FT_Property_Set and
164+ * @FT_Property_Get. Right now, there is a single property
165+ * @no-long-family-names available if FreeType is compiled with
166+ * PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.
167+ *
168+ * The PCF driver's module name is `pcf'.
169+ *
170+ */
171+
172+
173+ /**************************************************************************
174+ *
175+ * @section:
176+ * t1_cid_driver
177+ *
178+ * @title:
179+ * The Type 1 and CID drivers
180+ *
181+ * @abstract:
182+ * Controlling the Type~1 and CID driver modules.
183+ *
184+ * @description:
185+ * It is possible to control the behaviour of FreeType's Type~1 and
186+ * Type~1 CID drivers with @FT_Property_Set and @FT_Property_Get.
187+ *
188+ * Behind the scenes, both drivers use the Adobe CFF engine for hinting;
189+ * however, the used properties must be specified separately.
190+ *
191+ * The Type~1 driver's module name is `type1'; the CID driver's module
192+ * name is `t1cid'.
193+ *
194+ * Available properties are @hinting-engine, @no-stem-darkening,
195+ * @darkening-parameters, and @random-seed, as documented in the
196+ * @properties section.
197+ *
198+ * Please see the @cff_driver section for more details on the new
199+ * hinting engine.
200+ *
201+ */
202+
203+
204+ /**************************************************************************
205+ *
206+ * @section:
207+ * tt_driver
208+ *
209+ * @title:
210+ * The TrueType driver
211+ *
212+ * @abstract:
213+ * Controlling the TrueType driver module.
214+ *
215+ * @description:
216+ * While FreeType's TrueType driver doesn't expose API functions by
217+ * itself, it is possible to control its behaviour with @FT_Property_Set
218+ * and @FT_Property_Get. The following lists the available properties
219+ * together with the necessary macros and structures.
220+ *
221+ * The TrueType driver's module name is `truetype'.
222+ *
223+ * A single property @interpreter-version is available, as documented in
224+ * the @properties section.
225+ *
226+ * We start with a list of definitions, kindly provided by Greg
227+ * Hitchcock.
228+ *
229+ * _Bi-Level_ _Rendering_
230+ *
231+ * Monochromatic rendering, exclusively used in the early days of
232+ * TrueType by both Apple and Microsoft. Microsoft's GDI interface
233+ * supported hinting of the right-side bearing point, such that the
234+ * advance width could be non-linear. Most often this was done to
235+ * achieve some level of glyph symmetry. To enable reasonable
236+ * performance (e.g., not having to run hinting on all glyphs just to
237+ * get the widths) there was a bit in the head table indicating if the
238+ * side bearing was hinted, and additional tables, `hdmx' and `LTSH', to
239+ * cache hinting widths across multiple sizes and device aspect ratios.
240+ *
241+ * _Font_ _Smoothing_
242+ *
243+ * Microsoft's GDI implementation of anti-aliasing. Not traditional
244+ * anti-aliasing as the outlines were hinted before the sampling. The
245+ * widths matched the bi-level rendering.
246+ *
247+ * _ClearType_ _Rendering_
248+ *
249+ * Technique that uses physical subpixels to improve rendering on LCD
250+ * (and other) displays. Because of the higher resolution, many methods
251+ * of improving symmetry in glyphs through hinting the right-side
252+ * bearing were no longer necessary. This lead to what GDI calls
253+ * `natural widths' ClearType, see
254+ * http://www.beatstamm.com/typography/RTRCh4.htm#Sec21. Since hinting
255+ * has extra resolution, most non-linearity went away, but it is still
256+ * possible for hints to change the advance widths in this mode.
257+ *
258+ * _ClearType_ _Compatible_ _Widths_
259+ *
260+ * One of the earliest challenges with ClearType was allowing the
261+ * implementation in GDI to be selected without requiring all UI and
262+ * documents to reflow. To address this, a compatible method of
263+ * rendering ClearType was added where the font hints are executed once
264+ * to determine the width in bi-level rendering, and then re-run in
265+ * ClearType, with the difference in widths being absorbed in the font
266+ * hints for ClearType (mostly in the white space of hints); see
267+ * http://www.beatstamm.com/typography/RTRCh4.htm#Sec20. Somewhat by
268+ * definition, compatible width ClearType allows for non-linear widths,
269+ * but only when the bi-level version has non-linear widths.
270+ *
271+ * _ClearType_ _Subpixel_ _Positioning_
272+ *
273+ * One of the nice benefits of ClearType is the ability to more crisply
274+ * display fractional widths; unfortunately, the GDI model of integer
275+ * bitmaps did not support this. However, the WPF and Direct Write
276+ * frameworks do support fractional widths. DWrite calls this `natural
277+ * mode', not to be confused with GDI's `natural widths'. Subpixel
278+ * positioning, in the current implementation of Direct Write,
279+ * unfortunately does not support hinted advance widths, see
280+ * http://www.beatstamm.com/typography/RTRCh4.htm#Sec22. Note that the
281+ * TrueType interpreter fully allows the advance width to be adjusted in
282+ * this mode, just the DWrite client will ignore those changes.
283+ *
284+ * _ClearType_ _Backward_ _Compatibility_
285+ *
286+ * This is a set of exceptions made in the TrueType interpreter to
287+ * minimize hinting techniques that were problematic with the extra
288+ * resolution of ClearType; see
289+ * http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and
290+ * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx.
291+ * This technique is not to be confused with ClearType compatible
292+ * widths. ClearType backward compatibility has no direct impact on
293+ * changing advance widths, but there might be an indirect impact on
294+ * disabling some deltas. This could be worked around in backward
295+ * compatibility mode.
296+ *
297+ * _Native_ _ClearType_ _Mode_
298+ *
299+ * (Not to be confused with `natural widths'.) This mode removes all
300+ * the exceptions in the TrueType interpreter when running with
301+ * ClearType. Any issues on widths would still apply, though.
302+ *
303+ */
304+
305+
306+ /**************************************************************************
307+ *
308+ * @section:
309+ * properties
310+ *
311+ * @title:
312+ * Driver properties
313+ *
314+ * @abstract:
315+ * Controlling driver modules.
316+ *
317+ * @description:
318+ * Driver modules can be controlled by setting and unsetting properties,
319+ * using the functions @FT_Property_Set and @FT_Property_Get. This
320+ * section documents the available properties, together with auxiliary
321+ * macros and structures.
322+ *
323+ */
324+
325+
326+ /**************************************************************************
327+ *
328+ * @enum:
329+ * FT_HINTING_XXX
330+ *
331+ * @description:
332+ * A list of constants used for the @hinting-engine property to
333+ * select the hinting engine for CFF, Type~1, and CID fonts.
334+ *
335+ * @values:
336+ * FT_HINTING_FREETYPE ::
337+ * Use the old FreeType hinting engine.
338+ *
339+ * FT_HINTING_ADOBE ::
340+ * Use the hinting engine contributed by Adobe.
341+ *
342+ * @since:
343+ * 2.9
344+ *
345+ */
346+#define FT_HINTING_FREETYPE 0
347+#define FT_HINTING_ADOBE 1
348+
349+ /* these constants (introduced in 2.4.12) are deprecated */
350+#define FT_CFF_HINTING_FREETYPE FT_HINTING_FREETYPE
351+#define FT_CFF_HINTING_ADOBE FT_HINTING_ADOBE
352+
353+
354+ /**************************************************************************
355+ *
356+ * @property:
357+ * hinting-engine
358+ *
359+ * @description:
360+ * Thanks to Adobe, which contributed a new hinting (and parsing)
361+ * engine, an application can select between `freetype' and `adobe' if
362+ * compiled with CFF_CONFIG_OPTION_OLD_ENGINE. If this configuration
363+ * macro isn't defined, `hinting-engine' does nothing.
364+ *
365+ * The same holds for the Type~1 and CID modules if compiled with
366+ * T1_CONFIG_OPTION_OLD_ENGINE.
367+ *
368+ * For the `cff' module, the default engine is `freetype' if
369+ * CFF_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe' otherwise.
370+ *
371+ * For both the `type1' and `t1cid' modules, the default engine is
372+ * `freetype' if T1_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe'
373+ * otherwise.
374+ *
375+ * The following example code demonstrates how to select Adobe's hinting
376+ * engine for the `cff' module (omitting the error handling).
377+ *
378+ * {
379+ * FT_Library library;
380+ * FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE;
381+ *
382+ *
383+ * FT_Init_FreeType( &library );
384+ *
385+ * FT_Property_Set( library, "cff",
386+ * "hinting-engine", &hinting_engine );
387+ * }
388+ *
389+ * @note:
390+ * This property can be used with @FT_Property_Get also.
391+ *
392+ * This property can be set via the `FREETYPE_PROPERTIES' environment
393+ * variable (using values `adobe' or `freetype').
394+ *
395+ * @since:
396+ * 2.4.12 (for `cff' module)
397+ *
398+ * 2.9 (for `type1' and `t1cid' modules)
399+ *
400+ */
401+
402+
403+ /**************************************************************************
404+ *
405+ * @property:
406+ * no-stem-darkening
407+ *
408+ * @description:
409+ * All glyphs that pass through the auto-hinter will be emboldened
410+ * unless this property is set to TRUE. The same is true for the CFF,
411+ * Type~1, and CID font modules if the `Adobe' engine is selected (which
412+ * is the default).
413+ *
414+ * Stem darkening emboldens glyphs at smaller sizes to make them more
415+ * readable on common low-DPI screens when using linear alpha blending
416+ * and gamma correction, see @FT_Render_Glyph. When not using linear
417+ * alpha blending and gamma correction, glyphs will appear heavy and
418+ * fuzzy!
419+ *
420+ * Gamma correction essentially lightens fonts since shades of grey are
421+ * shifted to higher pixel values (=~higher brightness) to match the
422+ * original intention to the reality of our screens. The side-effect is
423+ * that glyphs `thin out'. Mac OS~X and Adobe's proprietary font
424+ * rendering library implement a counter-measure: stem darkening at
425+ * smaller sizes where shades of gray dominate. By emboldening a glyph
426+ * slightly in relation to its pixel size, individual pixels get higher
427+ * coverage of filled-in outlines and are therefore `blacker'. This
428+ * counteracts the `thinning out' of glyphs, making text remain readable
429+ * at smaller sizes.
430+ *
431+ * By default, the Adobe engines for CFF, Type~1, and CID fonts darken
432+ * stems at smaller sizes, regardless of hinting, to enhance contrast.
433+ * Setting this property, stem darkening gets switched off.
434+ *
435+ * For the auto-hinter, stem-darkening is experimental currently and
436+ * thus switched off by default (this is, `no-stem-darkening' is set to
437+ * TRUE by default). Total consistency with the CFF driver is not
438+ * achieved right now because the emboldening method differs and glyphs
439+ * must be scaled down on the Y-axis to keep outline points inside their
440+ * precomputed blue zones. The smaller the size (especially 9ppem and
441+ * down), the higher the loss of emboldening versus the CFF driver.
442+ *
443+ * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is
444+ * set.
445+ *
446+ * {
447+ * FT_Library library;
448+ * FT_Bool no_stem_darkening = TRUE;
449+ *
450+ *
451+ * FT_Init_FreeType( &library );
452+ *
453+ * FT_Property_Set( library, "cff",
454+ * "no-stem-darkening", &no_stem_darkening );
455+ * }
456+ *
457+ * @note:
458+ * This property can be used with @FT_Property_Get also.
459+ *
460+ * This property can be set via the `FREETYPE_PROPERTIES' environment
461+ * variable (using values 1 and 0 for `on' and `off', respectively).
462+ * It can also be set per face using @FT_Face_Properties with
463+ * @FT_PARAM_TAG_STEM_DARKENING.
464+ *
465+ * @since:
466+ * 2.4.12 (for `cff' module)
467+ *
468+ * 2.6.2 (for `autofitter' module)
469+ *
470+ * 2.9 (for `type1' and `t1cid' modules)
471+ *
472+ */
473+
474+
475+ /**************************************************************************
476+ *
477+ * @property:
478+ * darkening-parameters
479+ *
480+ * @description:
481+ * By default, the Adobe hinting engine, as used by the CFF, Type~1, and
482+ * CID font drivers, darkens stems as follows (if the
483+ * `no-stem-darkening' property isn't set):
484+ *
485+ * {
486+ * stem width <= 0.5px: darkening amount = 0.4px
487+ * stem width = 1px: darkening amount = 0.275px
488+ * stem width = 1.667px: darkening amount = 0.275px
489+ * stem width >= 2.333px: darkening amount = 0px
490+ * }
491+ *
492+ * and piecewise linear in-between. At configuration time, these four
493+ * control points can be set with the macro
494+ * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS'; the CFF, Type~1, and CID
495+ * drivers share these values. At runtime, the control points can be
496+ * changed using the `darkening-parameters' property, as the following
497+ * example demonstrates for the Type~1 driver.
498+ *
499+ * {
500+ * FT_Library library;
501+ * FT_Int darken_params[8] = { 500, 300, // x1, y1
502+ * 1000, 200, // x2, y2
503+ * 1500, 100, // x3, y3
504+ * 2000, 0 }; // x4, y4
505+ *
506+ *
507+ * FT_Init_FreeType( &library );
508+ *
509+ * FT_Property_Set( library, "type1",
510+ * "darkening-parameters", darken_params );
511+ * }
512+ *
513+ * The x~values give the stem width, and the y~values the darkening
514+ * amount. The unit is 1000th of pixels. All coordinate values must be
515+ * positive; the x~values must be monotonically increasing; the
516+ * y~values must be monotonically decreasing and smaller than or
517+ * equal to 500 (corresponding to half a pixel); the slope of each
518+ * linear piece must be shallower than -1 (e.g., -.4).
519+ *
520+ * The auto-hinter provides this property, too, as an experimental
521+ * feature. See @no-stem-darkening for more.
522+ *
523+ * @note:
524+ * This property can be used with @FT_Property_Get also.
525+ *
526+ * This property can be set via the `FREETYPE_PROPERTIES' environment
527+ * variable, using eight comma-separated integers without spaces. Here
528+ * the above example, using `\' to break the line for readability.
529+ *
530+ * {
531+ * FREETYPE_PROPERTIES=\
532+ * type1:darkening-parameters=500,300,1000,200,1500,100,2000,0
533+ * }
534+ *
535+ * @since:
536+ * 2.5.1 (for `cff' module)
537+ *
538+ * 2.6.2 (for `autofitter' module)
539+ *
540+ * 2.9 (for `type1' and `t1cid' modules)
541+ *
542+ */
543+
544+
545+ /**************************************************************************
546+ *
547+ * @property:
548+ * random-seed
549+ *
550+ * @description:
551+ * By default, the seed value for the CFF `random' operator and the
552+ * similar `0 28 callothersubr pop' command for the Type~1 and CID
553+ * drivers is set to a random value. However, mainly for debugging
554+ * purposes, it is often necessary to use a known value as a seed so
555+ * that the pseudo-random number sequences generated by `random' are
556+ * repeatable.
557+ *
558+ * The `random-seed' property does that. Its argument is a signed 32bit
559+ * integer; if the value is zero or negative, the seed given by the
560+ * `intitialRandomSeed' private DICT operator in a CFF file gets used
561+ * (or a default value if there is no such operator). If the value is
562+ * positive, use it instead of `initialRandomSeed', which is
563+ * consequently ignored.
564+ *
565+ * @note:
566+ * This property can be set via the `FREETYPE_PROPERTIES' environment
567+ * variable. It can also be set per face using @FT_Face_Properties with
568+ * @FT_PARAM_TAG_RANDOM_SEED.
569+ *
570+ * @since:
571+ * 2.8 (for `cff' module)
572+ *
573+ * 2.9 (for `type1' and `t1cid' modules)
574+ *
575+ */
576+
577+
578+ /**************************************************************************
579+ *
580+ * @property:
581+ * no-long-family-names
582+ *
583+ * @description:
584+ * If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling
585+ * FreeType, the PCF driver constructs long family names.
586+ *
587+ * There are many PCF fonts just called `Fixed' which look completely
588+ * different, and which have nothing to do with each other. When
589+ * selecting `Fixed' in KDE or Gnome one gets results that appear rather
590+ * random, the style changes often if one changes the size and one
591+ * cannot select some fonts at all. The improve this situation, the PCF
592+ * module prepends the foundry name (plus a space) to the family name.
593+ * It also checks whether there are `wide' characters; all put together,
594+ * family names like `Sony Fixed' or `Misc Fixed Wide' are constructed.
595+ *
596+ * If `no-long-family-names' is set, this feature gets switched off.
597+ *
598+ * {
599+ * FT_Library library;
600+ * FT_Bool no_long_family_names = TRUE;
601+ *
602+ *
603+ * FT_Init_FreeType( &library );
604+ *
605+ * FT_Property_Set( library, "pcf",
606+ * "no-long-family-names",
607+ * &no_long_family_names );
608+ * }
609+ *
610+ * @note:
611+ * This property can be used with @FT_Property_Get also.
612+ *
613+ * This property can be set via the `FREETYPE_PROPERTIES' environment
614+ * variable (using values 1 and 0 for `on' and `off', respectively).
615+ *
616+ * @since:
617+ * 2.8
618+ */
619+
620+
621+ /**************************************************************************
622+ *
623+ * @enum:
624+ * TT_INTERPRETER_VERSION_XXX
625+ *
626+ * @description:
627+ * A list of constants used for the @interpreter-version property to
628+ * select the hinting engine for Truetype fonts.
629+ *
630+ * The numeric value in the constant names represents the version
631+ * number as returned by the `GETINFO' bytecode instruction.
632+ *
633+ * @values:
634+ * TT_INTERPRETER_VERSION_35 ::
635+ * Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in
636+ * Windows~98; only grayscale and B/W rasterizing is supported.
637+ *
638+ * TT_INTERPRETER_VERSION_38 ::
639+ * Version~38 corresponds to MS rasterizer v.1.9; it is roughly
640+ * equivalent to the hinting provided by DirectWrite ClearType (as can
641+ * be found, for example, in the Internet Explorer~9 running on
642+ * Windows~7). It is used in FreeType to select the `Infinality'
643+ * subpixel hinting code. The code may be removed in a future
644+ * version.
645+ *
646+ * TT_INTERPRETER_VERSION_40 ::
647+ * Version~40 corresponds to MS rasterizer v.2.1; it is roughly
648+ * equivalent to the hinting provided by DirectWrite ClearType (as can
649+ * be found, for example, in Microsoft's Edge Browser on Windows~10).
650+ * It is used in FreeType to select the `minimal' subpixel hinting
651+ * code, a stripped-down and higher performance version of the
652+ * `Infinality' code.
653+ *
654+ * @note:
655+ * This property controls the behaviour of the bytecode interpreter
656+ * and thus how outlines get hinted. It does *not* control how glyph
657+ * get rasterized! In particular, it does not control subpixel color
658+ * filtering.
659+ *
660+ * If FreeType has not been compiled with the configuration option
661+ * TT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 or~40 causes
662+ * an `FT_Err_Unimplemented_Feature' error.
663+ *
664+ * Depending on the graphics framework, Microsoft uses different
665+ * bytecode and rendering engines. As a consequence, the version
666+ * numbers returned by a call to the `GETINFO' bytecode instruction are
667+ * more convoluted than desired.
668+ *
669+ * Here are two tables that try to shed some light on the possible
670+ * values for the MS rasterizer engine, together with the additional
671+ * features introduced by it.
672+ *
673+ * {
674+ * GETINFO framework version feature
675+ * -------------------------------------------------------------------
676+ * 3 GDI (Win 3.1), v1.0 16-bit, first version
677+ * TrueImage
678+ * 33 GDI (Win NT 3.1), v1.5 32-bit
679+ * HP Laserjet
680+ * 34 GDI (Win 95) v1.6 font smoothing,
681+ * new SCANTYPE opcode
682+ * 35 GDI (Win 98/2000) v1.7 (UN)SCALED_COMPONENT_OFFSET
683+ * bits in composite glyphs
684+ * 36 MGDI (Win CE 2) v1.6+ classic ClearType
685+ * 37 GDI (XP and later), v1.8 ClearType
686+ * GDI+ old (before Vista)
687+ * 38 GDI+ old (Vista, Win 7), v1.9 subpixel ClearType,
688+ * WPF Y-direction ClearType,
689+ * additional error checking
690+ * 39 DWrite (before Win 8) v2.0 subpixel ClearType flags
691+ * in GETINFO opcode,
692+ * bug fixes
693+ * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag
694+ * DWrite (Win 8) in GETINFO opcode,
695+ * Gray ClearType
696+ * }
697+ *
698+ * The `version' field gives a rough orientation only, since some
699+ * applications provided certain features much earlier (as an example,
700+ * Microsoft Reader used subpixel and Y-direction ClearType already in
701+ * Windows 2000). Similarly, updates to a given framework might include
702+ * improved hinting support.
703+ *
704+ * {
705+ * version sampling rendering comment
706+ * x y x y
707+ * --------------------------------------------------------------
708+ * v1.0 normal normal B/W B/W bi-level
709+ * v1.6 high high gray gray grayscale
710+ * v1.8 high normal color-filter B/W (GDI) ClearType
711+ * v1.9 high high color-filter gray Color ClearType
712+ * v2.1 high normal gray B/W Gray ClearType
713+ * v2.1 high high gray gray Gray ClearType
714+ * }
715+ *
716+ * Color and Gray ClearType are the two available variants of
717+ * `Y-direction ClearType', meaning grayscale rasterization along the
718+ * Y-direction; the name used in the TrueType specification for this
719+ * feature is `symmetric smoothing'. `Classic ClearType' is the
720+ * original algorithm used before introducing a modified version in
721+ * Win~XP. Another name for v1.6's grayscale rendering is `font
722+ * smoothing', and `Color ClearType' is sometimes also called `DWrite
723+ * ClearType'. To differentiate between today's Color ClearType and the
724+ * earlier ClearType variant with B/W rendering along the vertical axis,
725+ * the latter is sometimes called `GDI ClearType'.
726+ *
727+ * `Normal' and `high' sampling describe the (virtual) resolution to
728+ * access the rasterized outline after the hinting process. `Normal'
729+ * means 1 sample per grid line (i.e., B/W). In the current Microsoft
730+ * implementation, `high' means an extra virtual resolution of 16x16 (or
731+ * 16x1) grid lines per pixel for bytecode instructions like `MIRP'.
732+ * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid
733+ * lines for color filtering if Color ClearType is activated.
734+ *
735+ * Note that `Gray ClearType' is essentially the same as v1.6's
736+ * grayscale rendering. However, the GETINFO instruction handles it
737+ * differently: v1.6 returns bit~12 (hinting for grayscale), while v2.1
738+ * returns bits~13 (hinting for ClearType), 18 (symmetrical smoothing),
739+ * and~19 (Gray ClearType). Also, this mode respects bits 2 and~3 for
740+ * the version~1 gasp table exclusively (like Color ClearType), while
741+ * v1.6 only respects the values of version~0 (bits 0 and~1).
742+ *
743+ * Keep in mind that the features of the above interpreter versions
744+ * might not map exactly to FreeType features or behavior because it is
745+ * a fundamentally different library with different internals.
746+ *
747+ */
748+#define TT_INTERPRETER_VERSION_35 35
749+#define TT_INTERPRETER_VERSION_38 38
750+#define TT_INTERPRETER_VERSION_40 40
751+
752+
753+ /**************************************************************************
754+ *
755+ * @property:
756+ * interpreter-version
757+ *
758+ * @description:
759+ * Currently, three versions are available, two representing the
760+ * bytecode interpreter with subpixel hinting support (old `Infinality'
761+ * code and new stripped-down and higher performance `minimal' code) and
762+ * one without, respectively. The default is subpixel support if
763+ * TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel support
764+ * otherwise (since it isn't available then).
765+ *
766+ * If subpixel hinting is on, many TrueType bytecode instructions behave
767+ * differently compared to B/W or grayscale rendering (except if `native
768+ * ClearType' is selected by the font). Microsoft's main idea is to
769+ * render at a much increased horizontal resolution, then sampling down
770+ * the created output to subpixel precision. However, many older fonts
771+ * are not suited to this and must be specially taken care of by
772+ * applying (hardcoded) tweaks in Microsoft's interpreter.
773+ *
774+ * Details on subpixel hinting and some of the necessary tweaks can be
775+ * found in Greg Hitchcock's whitepaper at
776+ * `https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'.
777+ * Note that FreeType currently doesn't really `subpixel hint' (6x1, 6x2,
778+ * or 6x5 supersampling) like discussed in the paper. Depending on the
779+ * chosen interpreter, it simply ignores instructions on vertical stems
780+ * to arrive at very similar results.
781+ *
782+ * The following example code demonstrates how to deactivate subpixel
783+ * hinting (omitting the error handling).
784+ *
785+ * {
786+ * FT_Library library;
787+ * FT_Face face;
788+ * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35;
789+ *
790+ *
791+ * FT_Init_FreeType( &library );
792+ *
793+ * FT_Property_Set( library, "truetype",
794+ * "interpreter-version",
795+ * &interpreter_version );
796+ * }
797+ *
798+ * @note:
799+ * This property can be used with @FT_Property_Get also.
800+ *
801+ * This property can be set via the `FREETYPE_PROPERTIES' environment
802+ * variable (using values `35', `38', or `40').
803+ *
804+ * @since:
805+ * 2.5
806+ */
807+
808+
809+ /**************************************************************************
810+ *
811+ * @property:
812+ * glyph-to-script-map
813+ *
814+ * @description:
815+ * *Experimental* *only*
816+ *
817+ * The auto-hinter provides various script modules to hint glyphs.
818+ * Examples of supported scripts are Latin or CJK. Before a glyph is
819+ * auto-hinted, the Unicode character map of the font gets examined, and
820+ * the script is then determined based on Unicode character ranges, see
821+ * below.
822+ *
823+ * OpenType fonts, however, often provide much more glyphs than
824+ * character codes (small caps, superscripts, ligatures, swashes, etc.),
825+ * to be controlled by so-called `features'. Handling OpenType features
826+ * can be quite complicated and thus needs a separate library on top of
827+ * FreeType.
828+ *
829+ * The mapping between glyph indices and scripts (in the auto-hinter
830+ * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an
831+ * array with `num_glyphs' elements, as found in the font's @FT_Face
832+ * structure. The `glyph-to-script-map' property returns a pointer to
833+ * this array, which can be modified as needed. Note that the
834+ * modification should happen before the first glyph gets processed by
835+ * the auto-hinter so that the global analysis of the font shapes
836+ * actually uses the modified mapping.
837+ *
838+ * The following example code demonstrates how to access it (omitting
839+ * the error handling).
840+ *
841+ * {
842+ * FT_Library library;
843+ * FT_Face face;
844+ * FT_Prop_GlyphToScriptMap prop;
845+ *
846+ *
847+ * FT_Init_FreeType( &library );
848+ * FT_New_Face( library, "foo.ttf", 0, &face );
849+ *
850+ * prop.face = face;
851+ *
852+ * FT_Property_Get( library, "autofitter",
853+ * "glyph-to-script-map", &prop );
854+ *
855+ * // adjust `prop.map' as needed right here
856+ *
857+ * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT );
858+ * }
859+ *
860+ * @since:
861+ * 2.4.11
862+ *
863+ */
864+
865+
866+ /**************************************************************************
867+ *
868+ * @enum:
869+ * FT_AUTOHINTER_SCRIPT_XXX
870+ *
871+ * @description:
872+ * *Experimental* *only*
873+ *
874+ * A list of constants used for the @glyph-to-script-map property to
875+ * specify the script submodule the auto-hinter should use for hinting a
876+ * particular glyph.
877+ *
878+ * @values:
879+ * FT_AUTOHINTER_SCRIPT_NONE ::
880+ * Don't auto-hint this glyph.
881+ *
882+ * FT_AUTOHINTER_SCRIPT_LATIN ::
883+ * Apply the latin auto-hinter. For the auto-hinter, `latin' is a
884+ * very broad term, including Cyrillic and Greek also since characters
885+ * from those scripts share the same design constraints.
886+ *
887+ * By default, characters from the following Unicode ranges are
888+ * assigned to this submodule.
889+ *
890+ * {
891+ * U+0020 - U+007F // Basic Latin (no control characters)
892+ * U+00A0 - U+00FF // Latin-1 Supplement (no control characters)
893+ * U+0100 - U+017F // Latin Extended-A
894+ * U+0180 - U+024F // Latin Extended-B
895+ * U+0250 - U+02AF // IPA Extensions
896+ * U+02B0 - U+02FF // Spacing Modifier Letters
897+ * U+0300 - U+036F // Combining Diacritical Marks
898+ * U+0370 - U+03FF // Greek and Coptic
899+ * U+0400 - U+04FF // Cyrillic
900+ * U+0500 - U+052F // Cyrillic Supplement
901+ * U+1D00 - U+1D7F // Phonetic Extensions
902+ * U+1D80 - U+1DBF // Phonetic Extensions Supplement
903+ * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement
904+ * U+1E00 - U+1EFF // Latin Extended Additional
905+ * U+1F00 - U+1FFF // Greek Extended
906+ * U+2000 - U+206F // General Punctuation
907+ * U+2070 - U+209F // Superscripts and Subscripts
908+ * U+20A0 - U+20CF // Currency Symbols
909+ * U+2150 - U+218F // Number Forms
910+ * U+2460 - U+24FF // Enclosed Alphanumerics
911+ * U+2C60 - U+2C7F // Latin Extended-C
912+ * U+2DE0 - U+2DFF // Cyrillic Extended-A
913+ * U+2E00 - U+2E7F // Supplemental Punctuation
914+ * U+A640 - U+A69F // Cyrillic Extended-B
915+ * U+A720 - U+A7FF // Latin Extended-D
916+ * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures)
917+ * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols
918+ * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement
919+ * }
920+ *
921+ * FT_AUTOHINTER_SCRIPT_CJK ::
922+ * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old
923+ * Vietnamese, and some other scripts.
924+ *
925+ * By default, characters from the following Unicode ranges are
926+ * assigned to this submodule.
927+ *
928+ * {
929+ * U+1100 - U+11FF // Hangul Jamo
930+ * U+2E80 - U+2EFF // CJK Radicals Supplement
931+ * U+2F00 - U+2FDF // Kangxi Radicals
932+ * U+2FF0 - U+2FFF // Ideographic Description Characters
933+ * U+3000 - U+303F // CJK Symbols and Punctuation
934+ * U+3040 - U+309F // Hiragana
935+ * U+30A0 - U+30FF // Katakana
936+ * U+3100 - U+312F // Bopomofo
937+ * U+3130 - U+318F // Hangul Compatibility Jamo
938+ * U+3190 - U+319F // Kanbun
939+ * U+31A0 - U+31BF // Bopomofo Extended
940+ * U+31C0 - U+31EF // CJK Strokes
941+ * U+31F0 - U+31FF // Katakana Phonetic Extensions
942+ * U+3200 - U+32FF // Enclosed CJK Letters and Months
943+ * U+3300 - U+33FF // CJK Compatibility
944+ * U+3400 - U+4DBF // CJK Unified Ideographs Extension A
945+ * U+4DC0 - U+4DFF // Yijing Hexagram Symbols
946+ * U+4E00 - U+9FFF // CJK Unified Ideographs
947+ * U+A960 - U+A97F // Hangul Jamo Extended-A
948+ * U+AC00 - U+D7AF // Hangul Syllables
949+ * U+D7B0 - U+D7FF // Hangul Jamo Extended-B
950+ * U+F900 - U+FAFF // CJK Compatibility Ideographs
951+ * U+FE10 - U+FE1F // Vertical forms
952+ * U+FE30 - U+FE4F // CJK Compatibility Forms
953+ * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms
954+ * U+1B000 - U+1B0FF // Kana Supplement
955+ * U+1D300 - U+1D35F // Tai Xuan Hing Symbols
956+ * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement
957+ * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B
958+ * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C
959+ * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D
960+ * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement
961+ * }
962+ *
963+ * FT_AUTOHINTER_SCRIPT_INDIC ::
964+ * Apply the indic auto-hinter, covering all major scripts from the
965+ * Indian sub-continent and some other related scripts like Thai, Lao,
966+ * or Tibetan.
967+ *
968+ * By default, characters from the following Unicode ranges are
969+ * assigned to this submodule.
970+ *
971+ * {
972+ * U+0900 - U+0DFF // Indic Range
973+ * U+0F00 - U+0FFF // Tibetan
974+ * U+1900 - U+194F // Limbu
975+ * U+1B80 - U+1BBF // Sundanese
976+ * U+A800 - U+A82F // Syloti Nagri
977+ * U+ABC0 - U+ABFF // Meetei Mayek
978+ * U+11800 - U+118DF // Sharada
979+ * }
980+ *
981+ * Note that currently Indic support is rudimentary only, missing blue
982+ * zone support.
983+ *
984+ * @since:
985+ * 2.4.11
986+ *
987+ */
988+#define FT_AUTOHINTER_SCRIPT_NONE 0
989+#define FT_AUTOHINTER_SCRIPT_LATIN 1
990+#define FT_AUTOHINTER_SCRIPT_CJK 2
991+#define FT_AUTOHINTER_SCRIPT_INDIC 3
992+
993+
994+ /**************************************************************************
995+ *
996+ * @struct:
997+ * FT_Prop_GlyphToScriptMap
998+ *
999+ * @description:
1000+ * *Experimental* *only*
1001+ *
1002+ * The data exchange structure for the @glyph-to-script-map property.
1003+ *
1004+ * @since:
1005+ * 2.4.11
1006+ *
1007+ */
1008+ typedef struct FT_Prop_GlyphToScriptMap_
1009+ {
1010+ FT_Face face;
1011+ FT_UShort* map;
1012+
1013+ } FT_Prop_GlyphToScriptMap;
1014+
1015+
1016+ /**************************************************************************
1017+ *
1018+ * @property:
1019+ * fallback-script
1020+ *
1021+ * @description:
1022+ * *Experimental* *only*
1023+ *
1024+ * If no auto-hinter script module can be assigned to a glyph, a
1025+ * fallback script gets assigned to it (see also the
1026+ * @glyph-to-script-map property). By default, this is
1027+ * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property,
1028+ * this fallback value can be changed.
1029+ *
1030+ * {
1031+ * FT_Library library;
1032+ * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE;
1033+ *
1034+ *
1035+ * FT_Init_FreeType( &library );
1036+ *
1037+ * FT_Property_Set( library, "autofitter",
1038+ * "fallback-script", &fallback_script );
1039+ * }
1040+ *
1041+ * @note:
1042+ * This property can be used with @FT_Property_Get also.
1043+ *
1044+ * It's important to use the right timing for changing this value: The
1045+ * creation of the glyph-to-script map that eventually uses the
1046+ * fallback script value gets triggered either by setting or reading a
1047+ * face-specific property like @glyph-to-script-map, or by auto-hinting
1048+ * any glyph from that face. In particular, if you have already created
1049+ * an @FT_Face structure but not loaded any glyph (using the
1050+ * auto-hinter), a change of the fallback script will affect this face.
1051+ *
1052+ * @since:
1053+ * 2.4.11
1054+ *
1055+ */
1056+
1057+
1058+ /**************************************************************************
1059+ *
1060+ * @property:
1061+ * default-script
1062+ *
1063+ * @description:
1064+ * *Experimental* *only*
1065+ *
1066+ * If FreeType gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make
1067+ * the HarfBuzz library access OpenType features for getting better
1068+ * glyph coverages, this property sets the (auto-fitter) script to be
1069+ * used for the default (OpenType) script data of a font's GSUB table.
1070+ * Features for the default script are intended for all scripts not
1071+ * explicitly handled in GSUB; an example is a `dlig' feature,
1072+ * containing the combination of the characters `T', `E', and `L' to
1073+ * form a `TEL' ligature.
1074+ *
1075+ * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the
1076+ * `default-script' property, this default value can be changed.
1077+ *
1078+ * {
1079+ * FT_Library library;
1080+ * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE;
1081+ *
1082+ *
1083+ * FT_Init_FreeType( &library );
1084+ *
1085+ * FT_Property_Set( library, "autofitter",
1086+ * "default-script", &default_script );
1087+ * }
1088+ *
1089+ * @note:
1090+ * This property can be used with @FT_Property_Get also.
1091+ *
1092+ * It's important to use the right timing for changing this value: The
1093+ * creation of the glyph-to-script map that eventually uses the
1094+ * default script value gets triggered either by setting or reading a
1095+ * face-specific property like @glyph-to-script-map, or by auto-hinting
1096+ * any glyph from that face. In particular, if you have already created
1097+ * an @FT_Face structure but not loaded any glyph (using the
1098+ * auto-hinter), a change of the default script will affect this face.
1099+ *
1100+ * @since:
1101+ * 2.5.3
1102+ *
1103+ */
1104+
1105+
1106+ /**************************************************************************
1107+ *
1108+ * @property:
1109+ * increase-x-height
1110+ *
1111+ * @description:
1112+ * For ppem values in the range 6~<= ppem <= `increase-x-height', round
1113+ * up the font's x~height much more often than normally. If the value
1114+ * is set to~0, which is the default, this feature is switched off. Use
1115+ * this property to improve the legibility of small font sizes if
1116+ * necessary.
1117+ *
1118+ * {
1119+ * FT_Library library;
1120+ * FT_Face face;
1121+ * FT_Prop_IncreaseXHeight prop;
1122+ *
1123+ *
1124+ * FT_Init_FreeType( &library );
1125+ * FT_New_Face( library, "foo.ttf", 0, &face );
1126+ * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 );
1127+ *
1128+ * prop.face = face;
1129+ * prop.limit = 14;
1130+ *
1131+ * FT_Property_Set( library, "autofitter",
1132+ * "increase-x-height", &prop );
1133+ * }
1134+ *
1135+ * @note:
1136+ * This property can be used with @FT_Property_Get also.
1137+ *
1138+ * Set this value right after calling @FT_Set_Char_Size, but before
1139+ * loading any glyph (using the auto-hinter).
1140+ *
1141+ * @since:
1142+ * 2.4.11
1143+ *
1144+ */
1145+
1146+
1147+ /**************************************************************************
1148+ *
1149+ * @struct:
1150+ * FT_Prop_IncreaseXHeight
1151+ *
1152+ * @description:
1153+ * The data exchange structure for the @increase-x-height property.
1154+ *
1155+ */
1156+ typedef struct FT_Prop_IncreaseXHeight_
1157+ {
1158+ FT_Face face;
1159+ FT_UInt limit;
1160+
1161+ } FT_Prop_IncreaseXHeight;
1162+
1163+
1164+ /**************************************************************************
1165+ *
1166+ * @property:
1167+ * warping
1168+ *
1169+ * @description:
1170+ * *Experimental* *only*
1171+ *
1172+ * If FreeType gets compiled with option AF_CONFIG_OPTION_USE_WARPER to
1173+ * activate the warp hinting code in the auto-hinter, this property
1174+ * switches warping on and off.
1175+ *
1176+ * Warping only works in `normal' auto-hinting mode replacing it.
1177+ * The idea of the code is to slightly scale and shift a glyph along
1178+ * the non-hinted dimension (which is usually the horizontal axis) so
1179+ * that as much of its segments are aligned (more or less) to the grid.
1180+ * To find out a glyph's optimal scaling and shifting value, various
1181+ * parameter combinations are tried and scored.
1182+ *
1183+ * By default, warping is off. The example below shows how to switch on
1184+ * warping (omitting the error handling).
1185+ *
1186+ * {
1187+ * FT_Library library;
1188+ * FT_Bool warping = 1;
1189+ *
1190+ *
1191+ * FT_Init_FreeType( &library );
1192+ *
1193+ * FT_Property_Set( library, "autofitter",
1194+ * "warping", &warping );
1195+ * }
1196+ *
1197+ * @note:
1198+ * This property can be used with @FT_Property_Get also.
1199+ *
1200+ * This property can be set via the `FREETYPE_PROPERTIES' environment
1201+ * variable (using values 1 and 0 for `on' and `off', respectively).
1202+ *
1203+ * The warping code can also change advance widths. Have a look at the
1204+ * `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure
1205+ * for details on improving inter-glyph distances while rendering.
1206+ *
1207+ * Since warping is a global property of the auto-hinter it is best to
1208+ * change its value before rendering any face. Otherwise, you should
1209+ * reload all faces that get auto-hinted in `normal' hinting mode.
1210+ *
1211+ * @since:
1212+ * 2.6
1213+ *
1214+ */
1215+
1216+
1217+ /* */
1218+
1219+
1220+FT_END_HEADER
1221+
1222+
1223+#endif /* FTDRIVER_H_ */
1224+
1225+
1226+/* END */
1@@ -0,0 +1,280 @@
2+/***************************************************************************/
3+/* */
4+/* fterrdef.h */
5+/* */
6+/* FreeType error codes (specification). */
7+/* */
8+/* Copyright 2002-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+ /*************************************************************************/
21+ /* */
22+ /* <Section> */
23+ /* error_code_values */
24+ /* */
25+ /* <Title> */
26+ /* Error Code Values */
27+ /* */
28+ /* <Abstract> */
29+ /* All possible error codes returned by FreeType functions. */
30+ /* */
31+ /* <Description> */
32+ /* The list below is taken verbatim from the file `fterrdef.h' */
33+ /* (loaded automatically by including `FT_FREETYPE_H'). The first */
34+ /* argument of the `FT_ERROR_DEF_' macro is the error label; by */
35+ /* default, the prefix `FT_Err_' gets added so that you get error */
36+ /* names like `FT_Err_Cannot_Open_Resource'. The second argument is */
37+ /* the error code, and the last argument an error string, which is not */
38+ /* used by FreeType. */
39+ /* */
40+ /* Within your application you should *only* use error names and */
41+ /* *never* its numeric values! The latter might (and actually do) */
42+ /* change in forthcoming FreeType versions. */
43+ /* */
44+ /* Macro `FT_NOERRORDEF_' defines `FT_Err_Ok', which is always zero. */
45+ /* See the `Error Enumerations' subsection how to automatically */
46+ /* generate a list of error strings. */
47+ /* */
48+ /*************************************************************************/
49+
50+
51+ /*************************************************************************/
52+ /* */
53+ /* <Enum> */
54+ /* FT_Err_XXX */
55+ /* */
56+ /*************************************************************************/
57+
58+ /* generic errors */
59+
60+ FT_NOERRORDEF_( Ok, 0x00,
61+ "no error" )
62+
63+ FT_ERRORDEF_( Cannot_Open_Resource, 0x01,
64+ "cannot open resource" )
65+ FT_ERRORDEF_( Unknown_File_Format, 0x02,
66+ "unknown file format" )
67+ FT_ERRORDEF_( Invalid_File_Format, 0x03,
68+ "broken file" )
69+ FT_ERRORDEF_( Invalid_Version, 0x04,
70+ "invalid FreeType version" )
71+ FT_ERRORDEF_( Lower_Module_Version, 0x05,
72+ "module version is too low" )
73+ FT_ERRORDEF_( Invalid_Argument, 0x06,
74+ "invalid argument" )
75+ FT_ERRORDEF_( Unimplemented_Feature, 0x07,
76+ "unimplemented feature" )
77+ FT_ERRORDEF_( Invalid_Table, 0x08,
78+ "broken table" )
79+ FT_ERRORDEF_( Invalid_Offset, 0x09,
80+ "broken offset within table" )
81+ FT_ERRORDEF_( Array_Too_Large, 0x0A,
82+ "array allocation size too large" )
83+ FT_ERRORDEF_( Missing_Module, 0x0B,
84+ "missing module" )
85+ FT_ERRORDEF_( Missing_Property, 0x0C,
86+ "missing property" )
87+
88+ /* glyph/character errors */
89+
90+ FT_ERRORDEF_( Invalid_Glyph_Index, 0x10,
91+ "invalid glyph index" )
92+ FT_ERRORDEF_( Invalid_Character_Code, 0x11,
93+ "invalid character code" )
94+ FT_ERRORDEF_( Invalid_Glyph_Format, 0x12,
95+ "unsupported glyph image format" )
96+ FT_ERRORDEF_( Cannot_Render_Glyph, 0x13,
97+ "cannot render this glyph format" )
98+ FT_ERRORDEF_( Invalid_Outline, 0x14,
99+ "invalid outline" )
100+ FT_ERRORDEF_( Invalid_Composite, 0x15,
101+ "invalid composite glyph" )
102+ FT_ERRORDEF_( Too_Many_Hints, 0x16,
103+ "too many hints" )
104+ FT_ERRORDEF_( Invalid_Pixel_Size, 0x17,
105+ "invalid pixel size" )
106+
107+ /* handle errors */
108+
109+ FT_ERRORDEF_( Invalid_Handle, 0x20,
110+ "invalid object handle" )
111+ FT_ERRORDEF_( Invalid_Library_Handle, 0x21,
112+ "invalid library handle" )
113+ FT_ERRORDEF_( Invalid_Driver_Handle, 0x22,
114+ "invalid module handle" )
115+ FT_ERRORDEF_( Invalid_Face_Handle, 0x23,
116+ "invalid face handle" )
117+ FT_ERRORDEF_( Invalid_Size_Handle, 0x24,
118+ "invalid size handle" )
119+ FT_ERRORDEF_( Invalid_Slot_Handle, 0x25,
120+ "invalid glyph slot handle" )
121+ FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26,
122+ "invalid charmap handle" )
123+ FT_ERRORDEF_( Invalid_Cache_Handle, 0x27,
124+ "invalid cache manager handle" )
125+ FT_ERRORDEF_( Invalid_Stream_Handle, 0x28,
126+ "invalid stream handle" )
127+
128+ /* driver errors */
129+
130+ FT_ERRORDEF_( Too_Many_Drivers, 0x30,
131+ "too many modules" )
132+ FT_ERRORDEF_( Too_Many_Extensions, 0x31,
133+ "too many extensions" )
134+
135+ /* memory errors */
136+
137+ FT_ERRORDEF_( Out_Of_Memory, 0x40,
138+ "out of memory" )
139+ FT_ERRORDEF_( Unlisted_Object, 0x41,
140+ "unlisted object" )
141+
142+ /* stream errors */
143+
144+ FT_ERRORDEF_( Cannot_Open_Stream, 0x51,
145+ "cannot open stream" )
146+ FT_ERRORDEF_( Invalid_Stream_Seek, 0x52,
147+ "invalid stream seek" )
148+ FT_ERRORDEF_( Invalid_Stream_Skip, 0x53,
149+ "invalid stream skip" )
150+ FT_ERRORDEF_( Invalid_Stream_Read, 0x54,
151+ "invalid stream read" )
152+ FT_ERRORDEF_( Invalid_Stream_Operation, 0x55,
153+ "invalid stream operation" )
154+ FT_ERRORDEF_( Invalid_Frame_Operation, 0x56,
155+ "invalid frame operation" )
156+ FT_ERRORDEF_( Nested_Frame_Access, 0x57,
157+ "nested frame access" )
158+ FT_ERRORDEF_( Invalid_Frame_Read, 0x58,
159+ "invalid frame read" )
160+
161+ /* raster errors */
162+
163+ FT_ERRORDEF_( Raster_Uninitialized, 0x60,
164+ "raster uninitialized" )
165+ FT_ERRORDEF_( Raster_Corrupted, 0x61,
166+ "raster corrupted" )
167+ FT_ERRORDEF_( Raster_Overflow, 0x62,
168+ "raster overflow" )
169+ FT_ERRORDEF_( Raster_Negative_Height, 0x63,
170+ "negative height while rastering" )
171+
172+ /* cache errors */
173+
174+ FT_ERRORDEF_( Too_Many_Caches, 0x70,
175+ "too many registered caches" )
176+
177+ /* TrueType and SFNT errors */
178+
179+ FT_ERRORDEF_( Invalid_Opcode, 0x80,
180+ "invalid opcode" )
181+ FT_ERRORDEF_( Too_Few_Arguments, 0x81,
182+ "too few arguments" )
183+ FT_ERRORDEF_( Stack_Overflow, 0x82,
184+ "stack overflow" )
185+ FT_ERRORDEF_( Code_Overflow, 0x83,
186+ "code overflow" )
187+ FT_ERRORDEF_( Bad_Argument, 0x84,
188+ "bad argument" )
189+ FT_ERRORDEF_( Divide_By_Zero, 0x85,
190+ "division by zero" )
191+ FT_ERRORDEF_( Invalid_Reference, 0x86,
192+ "invalid reference" )
193+ FT_ERRORDEF_( Debug_OpCode, 0x87,
194+ "found debug opcode" )
195+ FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88,
196+ "found ENDF opcode in execution stream" )
197+ FT_ERRORDEF_( Nested_DEFS, 0x89,
198+ "nested DEFS" )
199+ FT_ERRORDEF_( Invalid_CodeRange, 0x8A,
200+ "invalid code range" )
201+ FT_ERRORDEF_( Execution_Too_Long, 0x8B,
202+ "execution context too long" )
203+ FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C,
204+ "too many function definitions" )
205+ FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D,
206+ "too many instruction definitions" )
207+ FT_ERRORDEF_( Table_Missing, 0x8E,
208+ "SFNT font table missing" )
209+ FT_ERRORDEF_( Horiz_Header_Missing, 0x8F,
210+ "horizontal header (hhea) table missing" )
211+ FT_ERRORDEF_( Locations_Missing, 0x90,
212+ "locations (loca) table missing" )
213+ FT_ERRORDEF_( Name_Table_Missing, 0x91,
214+ "name table missing" )
215+ FT_ERRORDEF_( CMap_Table_Missing, 0x92,
216+ "character map (cmap) table missing" )
217+ FT_ERRORDEF_( Hmtx_Table_Missing, 0x93,
218+ "horizontal metrics (hmtx) table missing" )
219+ FT_ERRORDEF_( Post_Table_Missing, 0x94,
220+ "PostScript (post) table missing" )
221+ FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95,
222+ "invalid horizontal metrics" )
223+ FT_ERRORDEF_( Invalid_CharMap_Format, 0x96,
224+ "invalid character map (cmap) format" )
225+ FT_ERRORDEF_( Invalid_PPem, 0x97,
226+ "invalid ppem value" )
227+ FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98,
228+ "invalid vertical metrics" )
229+ FT_ERRORDEF_( Could_Not_Find_Context, 0x99,
230+ "could not find context" )
231+ FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A,
232+ "invalid PostScript (post) table format" )
233+ FT_ERRORDEF_( Invalid_Post_Table, 0x9B,
234+ "invalid PostScript (post) table" )
235+ FT_ERRORDEF_( DEF_In_Glyf_Bytecode, 0x9C,
236+ "found FDEF or IDEF opcode in glyf bytecode" )
237+ FT_ERRORDEF_( Missing_Bitmap, 0x9D,
238+ "missing bitmap in strike" )
239+
240+ /* CFF, CID, and Type 1 errors */
241+
242+ FT_ERRORDEF_( Syntax_Error, 0xA0,
243+ "opcode syntax error" )
244+ FT_ERRORDEF_( Stack_Underflow, 0xA1,
245+ "argument stack underflow" )
246+ FT_ERRORDEF_( Ignore, 0xA2,
247+ "ignore" )
248+ FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3,
249+ "no Unicode glyph name found" )
250+ FT_ERRORDEF_( Glyph_Too_Big, 0xA4,
251+ "glyph too big for hinting" )
252+
253+ /* BDF errors */
254+
255+ FT_ERRORDEF_( Missing_Startfont_Field, 0xB0,
256+ "`STARTFONT' field missing" )
257+ FT_ERRORDEF_( Missing_Font_Field, 0xB1,
258+ "`FONT' field missing" )
259+ FT_ERRORDEF_( Missing_Size_Field, 0xB2,
260+ "`SIZE' field missing" )
261+ FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3,
262+ "`FONTBOUNDINGBOX' field missing" )
263+ FT_ERRORDEF_( Missing_Chars_Field, 0xB4,
264+ "`CHARS' field missing" )
265+ FT_ERRORDEF_( Missing_Startchar_Field, 0xB5,
266+ "`STARTCHAR' field missing" )
267+ FT_ERRORDEF_( Missing_Encoding_Field, 0xB6,
268+ "`ENCODING' field missing" )
269+ FT_ERRORDEF_( Missing_Bbx_Field, 0xB7,
270+ "`BBX' field missing" )
271+ FT_ERRORDEF_( Bbx_Too_Big, 0xB8,
272+ "`BBX' too big" )
273+ FT_ERRORDEF_( Corrupted_Font_Header, 0xB9,
274+ "Font header corrupted or missing fields" )
275+ FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA,
276+ "Font glyphs corrupted or missing fields" )
277+
278+ /* */
279+
280+
281+/* END */
1@@ -0,0 +1,226 @@
2+/***************************************************************************/
3+/* */
4+/* fterrors.h */
5+/* */
6+/* FreeType error code handling (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+ /*************************************************************************/
21+ /* */
22+ /* <Section> */
23+ /* error_enumerations */
24+ /* */
25+ /* <Title> */
26+ /* Error Enumerations */
27+ /* */
28+ /* <Abstract> */
29+ /* How to handle errors and error strings. */
30+ /* */
31+ /* <Description> */
32+ /* The header file `fterrors.h' (which is automatically included by */
33+ /* `freetype.h' defines the handling of FreeType's enumeration */
34+ /* constants. It can also be used to generate error message strings */
35+ /* with a small macro trick explained below. */
36+ /* */
37+ /* *Error* *Formats* */
38+ /* */
39+ /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */
40+ /* defined in `ftoption.h' in order to make the higher byte indicate */
41+ /* the module where the error has happened (this is not compatible */
42+ /* with standard builds of FreeType~2, however). See the file */
43+ /* `ftmoderr.h' for more details. */
44+ /* */
45+ /* *Error* *Message* *Strings* */
46+ /* */
47+ /* Error definitions are set up with special macros that allow client */
48+ /* applications to build a table of error message strings. The */
49+ /* strings are not included in a normal build of FreeType~2 to save */
50+ /* space (most client applications do not use them). */
51+ /* */
52+ /* To do so, you have to define the following macros before including */
53+ /* this file. */
54+ /* */
55+ /* { */
56+ /* FT_ERROR_START_LIST */
57+ /* } */
58+ /* */
59+ /* This macro is called before anything else to define the start of */
60+ /* the error list. It is followed by several FT_ERROR_DEF calls. */
61+ /* */
62+ /* { */
63+ /* FT_ERROR_DEF( e, v, s ) */
64+ /* } */
65+ /* */
66+ /* This macro is called to define one single error. `e' is the error */
67+ /* code identifier (e.g., `Invalid_Argument'), `v' is the error's */
68+ /* numerical value, and `s' is the corresponding error string. */
69+ /* */
70+ /* { */
71+ /* FT_ERROR_END_LIST */
72+ /* } */
73+ /* */
74+ /* This macro ends the list. */
75+ /* */
76+ /* Additionally, you have to undefine `FTERRORS_H_' before #including */
77+ /* this file. */
78+ /* */
79+ /* Here is a simple example. */
80+ /* */
81+ /* { */
82+ /* #undef FTERRORS_H_ */
83+ /* #define FT_ERRORDEF( e, v, s ) { e, s }, */
84+ /* #define FT_ERROR_START_LIST { */
85+ /* #define FT_ERROR_END_LIST { 0, NULL } }; */
86+ /* */
87+ /* const struct */
88+ /* { */
89+ /* int err_code; */
90+ /* const char* err_msg; */
91+ /* } ft_errors[] = */
92+ /* */
93+ /* #include FT_ERRORS_H */
94+ /* } */
95+ /* */
96+ /* Note that `FT_Err_Ok' is _not_ defined with `FT_ERRORDEF' but with */
97+ /* `FT_NOERRORDEF'; it is always zero. */
98+ /* */
99+ /*************************************************************************/
100+
101+ /* */
102+
103+ /* In previous FreeType versions we used `__FTERRORS_H__'. However, */
104+ /* using two successive underscores in a non-system symbol name */
105+ /* violates the C (and C++) standard, so it was changed to the */
106+ /* current form. In spite of this, we have to make */
107+ /* */
108+ /* #undefine __FTERRORS_H__ */
109+ /* */
110+ /* work for backward compatibility. */
111+ /* */
112+#if !( defined( FTERRORS_H_ ) && defined ( __FTERRORS_H__ ) )
113+#define FTERRORS_H_
114+#define __FTERRORS_H__
115+
116+
117+ /* include module base error codes */
118+#include FT_MODULE_ERRORS_H
119+
120+
121+ /*******************************************************************/
122+ /*******************************************************************/
123+ /***** *****/
124+ /***** SETUP MACROS *****/
125+ /***** *****/
126+ /*******************************************************************/
127+ /*******************************************************************/
128+
129+
130+#undef FT_NEED_EXTERN_C
131+
132+
133+ /* FT_ERR_PREFIX is used as a prefix for error identifiers. */
134+ /* By default, we use `FT_Err_'. */
135+ /* */
136+#ifndef FT_ERR_PREFIX
137+#define FT_ERR_PREFIX FT_Err_
138+#endif
139+
140+
141+ /* FT_ERR_BASE is used as the base for module-specific errors. */
142+ /* */
143+#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
144+
145+#ifndef FT_ERR_BASE
146+#define FT_ERR_BASE FT_Mod_Err_Base
147+#endif
148+
149+#else
150+
151+#undef FT_ERR_BASE
152+#define FT_ERR_BASE 0
153+
154+#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */
155+
156+
157+ /* If FT_ERRORDEF is not defined, we need to define a simple */
158+ /* enumeration type. */
159+ /* */
160+#ifndef FT_ERRORDEF
161+
162+#define FT_ERRORDEF( e, v, s ) e = v,
163+#define FT_ERROR_START_LIST enum {
164+#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) };
165+
166+#ifdef __cplusplus
167+#define FT_NEED_EXTERN_C
168+ extern "C" {
169+#endif
170+
171+#endif /* !FT_ERRORDEF */
172+
173+
174+ /* this macro is used to define an error */
175+#define FT_ERRORDEF_( e, v, s ) \
176+ FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
177+
178+ /* this is only used for <module>_Err_Ok, which must be 0! */
179+#define FT_NOERRORDEF_( e, v, s ) \
180+ FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
181+
182+
183+#ifdef FT_ERROR_START_LIST
184+ FT_ERROR_START_LIST
185+#endif
186+
187+
188+ /* now include the error codes */
189+#include FT_ERROR_DEFINITIONS_H
190+
191+
192+#ifdef FT_ERROR_END_LIST
193+ FT_ERROR_END_LIST
194+#endif
195+
196+
197+ /*******************************************************************/
198+ /*******************************************************************/
199+ /***** *****/
200+ /***** SIMPLE CLEANUP *****/
201+ /***** *****/
202+ /*******************************************************************/
203+ /*******************************************************************/
204+
205+#ifdef FT_NEED_EXTERN_C
206+ }
207+#endif
208+
209+#undef FT_ERROR_START_LIST
210+#undef FT_ERROR_END_LIST
211+
212+#undef FT_ERRORDEF
213+#undef FT_ERRORDEF_
214+#undef FT_NOERRORDEF_
215+
216+#undef FT_NEED_EXTERN_C
217+#undef FT_ERR_BASE
218+
219+ /* FT_ERR_PREFIX is needed internally */
220+#ifndef FT2_BUILD_LIBRARY
221+#undef FT_ERR_PREFIX
222+#endif
223+
224+#endif /* !(FTERRORS_H_ && __FTERRORS_H__) */
225+
226+
227+/* END */
1@@ -0,0 +1,95 @@
2+/***************************************************************************/
3+/* */
4+/* ftfntfmt.h */
5+/* */
6+/* Support functions for font formats. */
7+/* */
8+/* Copyright 2002-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTFNTFMT_H_
21+#define FTFNTFMT_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+
36+ /*************************************************************************/
37+ /* */
38+ /* <Section> */
39+ /* font_formats */
40+ /* */
41+ /* <Title> */
42+ /* Font Formats */
43+ /* */
44+ /* <Abstract> */
45+ /* Getting the font format. */
46+ /* */
47+ /* <Description> */
48+ /* The single function in this section can be used to get the font */
49+ /* format. Note that this information is not needed normally; */
50+ /* however, there are special cases (like in PDF devices) where it is */
51+ /* important to differentiate, in spite of FreeType's uniform API. */
52+ /* */
53+ /*************************************************************************/
54+
55+
56+ /*************************************************************************/
57+ /* */
58+ /* <Function> */
59+ /* FT_Get_Font_Format */
60+ /* */
61+ /* <Description> */
62+ /* Return a string describing the format of a given face. Possible */
63+ /* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */
64+ /* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */
65+ /* */
66+ /* The return value is suitable to be used as an X11 FONT_PROPERTY. */
67+ /* */
68+ /* <Input> */
69+ /* face :: */
70+ /* Input face handle. */
71+ /* */
72+ /* <Return> */
73+ /* Font format string. NULL in case of error. */
74+ /* */
75+ /* <Note> */
76+ /* A deprecated name for the same function is */
77+ /* `FT_Get_X11_Font_Format'. */
78+ /* */
79+ FT_EXPORT( const char* )
80+ FT_Get_Font_Format( FT_Face face );
81+
82+
83+ /* deprecated */
84+ FT_EXPORT( const char* )
85+ FT_Get_X11_Font_Format( FT_Face face );
86+
87+
88+ /* */
89+
90+
91+FT_END_HEADER
92+
93+#endif /* FTFNTFMT_H_ */
94+
95+
96+/* END */
1@@ -0,0 +1,142 @@
2+/***************************************************************************/
3+/* */
4+/* ftgasp.h */
5+/* */
6+/* Access of TrueType's `gasp' table (specification). */
7+/* */
8+/* Copyright 2007-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTGASP_H_
21+#define FTGASP_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+
36+ /***************************************************************************
37+ *
38+ * @section:
39+ * gasp_table
40+ *
41+ * @title:
42+ * Gasp Table
43+ *
44+ * @abstract:
45+ * Retrieving TrueType `gasp' table entries.
46+ *
47+ * @description:
48+ * The function @FT_Get_Gasp can be used to query a TrueType or OpenType
49+ * font for specific entries in its `gasp' table, if any. This is
50+ * mainly useful when implementing native TrueType hinting with the
51+ * bytecode interpreter to duplicate the Windows text rendering results.
52+ */
53+
54+ /*************************************************************************
55+ *
56+ * @enum:
57+ * FT_GASP_XXX
58+ *
59+ * @description:
60+ * A list of values and/or bit-flags returned by the @FT_Get_Gasp
61+ * function.
62+ *
63+ * @values:
64+ * FT_GASP_NO_TABLE ::
65+ * This special value means that there is no GASP table in this face.
66+ * It is up to the client to decide what to do.
67+ *
68+ * FT_GASP_DO_GRIDFIT ::
69+ * Grid-fitting and hinting should be performed at the specified ppem.
70+ * This *really* means TrueType bytecode interpretation. If this bit
71+ * is not set, no hinting gets applied.
72+ *
73+ * FT_GASP_DO_GRAY ::
74+ * Anti-aliased rendering should be performed at the specified ppem.
75+ * If not set, do monochrome rendering.
76+ *
77+ * FT_GASP_SYMMETRIC_SMOOTHING ::
78+ * If set, smoothing along multiple axes must be used with ClearType.
79+ *
80+ * FT_GASP_SYMMETRIC_GRIDFIT ::
81+ * Grid-fitting must be used with ClearType's symmetric smoothing.
82+ *
83+ * @note:
84+ * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be
85+ * used for standard font rasterization only. Independently of that,
86+ * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to
87+ * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and
88+ * `FT_GASP_DO_GRAY' are consequently ignored).
89+ *
90+ * `ClearType' is Microsoft's implementation of LCD rendering, partly
91+ * protected by patents.
92+ *
93+ * @since:
94+ * 2.3.0
95+ */
96+#define FT_GASP_NO_TABLE -1
97+#define FT_GASP_DO_GRIDFIT 0x01
98+#define FT_GASP_DO_GRAY 0x02
99+#define FT_GASP_SYMMETRIC_GRIDFIT 0x04
100+#define FT_GASP_SYMMETRIC_SMOOTHING 0x08
101+
102+
103+ /*************************************************************************
104+ *
105+ * @func:
106+ * FT_Get_Gasp
107+ *
108+ * @description:
109+ * For a TrueType or OpenType font file, return the rasterizer behaviour
110+ * flags from the font's `gasp' table corresponding to a given
111+ * character pixel size.
112+ *
113+ * @input:
114+ * face :: The source face handle.
115+ *
116+ * ppem :: The vertical character pixel size.
117+ *
118+ * @return:
119+ * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no
120+ * `gasp' table in the face.
121+ *
122+ * @note:
123+ * If you want to use the MM functionality of OpenType variation fonts
124+ * (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this
125+ * function *after* setting an instance since the return values can
126+ * change.
127+ *
128+ * @since:
129+ * 2.3.0
130+ */
131+ FT_EXPORT( FT_Int )
132+ FT_Get_Gasp( FT_Face face,
133+ FT_UInt ppem );
134+
135+ /* */
136+
137+
138+FT_END_HEADER
139+
140+#endif /* FTGASP_H_ */
141+
142+
143+/* END */
1@@ -0,0 +1,614 @@
2+/***************************************************************************/
3+/* */
4+/* ftglyph.h */
5+/* */
6+/* FreeType convenience functions to handle glyphs (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+ /*************************************************************************/
21+ /* */
22+ /* This file contains the definition of several convenience functions */
23+ /* that can be used by client applications to easily retrieve glyph */
24+ /* bitmaps and outlines from a given face. */
25+ /* */
26+ /* These functions should be optional if you are writing a font server */
27+ /* or text layout engine on top of FreeType. However, they are pretty */
28+ /* handy for many other simple uses of the library. */
29+ /* */
30+ /*************************************************************************/
31+
32+
33+#ifndef FTGLYPH_H_
34+#define FTGLYPH_H_
35+
36+
37+#include <ft2build.h>
38+#include FT_FREETYPE_H
39+
40+#ifdef FREETYPE_H
41+#error "freetype.h of FreeType 1 has been loaded!"
42+#error "Please fix the directory search order for header files"
43+#error "so that freetype.h of FreeType 2 is found first."
44+#endif
45+
46+
47+FT_BEGIN_HEADER
48+
49+
50+ /*************************************************************************/
51+ /* */
52+ /* <Section> */
53+ /* glyph_management */
54+ /* */
55+ /* <Title> */
56+ /* Glyph Management */
57+ /* */
58+ /* <Abstract> */
59+ /* Generic interface to manage individual glyph data. */
60+ /* */
61+ /* <Description> */
62+ /* This section contains definitions used to manage glyph data */
63+ /* through generic FT_Glyph objects. Each of them can contain a */
64+ /* bitmap, a vector outline, or even images in other formats. */
65+ /* */
66+ /*************************************************************************/
67+
68+
69+ /* forward declaration to a private type */
70+ typedef struct FT_Glyph_Class_ FT_Glyph_Class;
71+
72+
73+ /*************************************************************************/
74+ /* */
75+ /* <Type> */
76+ /* FT_Glyph */
77+ /* */
78+ /* <Description> */
79+ /* Handle to an object used to model generic glyph images. It is a */
80+ /* pointer to the @FT_GlyphRec structure and can contain a glyph */
81+ /* bitmap or pointer. */
82+ /* */
83+ /* <Note> */
84+ /* Glyph objects are not owned by the library. You must thus release */
85+ /* them manually (through @FT_Done_Glyph) _before_ calling */
86+ /* @FT_Done_FreeType. */
87+ /* */
88+ typedef struct FT_GlyphRec_* FT_Glyph;
89+
90+
91+ /*************************************************************************/
92+ /* */
93+ /* <Struct> */
94+ /* FT_GlyphRec */
95+ /* */
96+ /* <Description> */
97+ /* The root glyph structure contains a given glyph image plus its */
98+ /* advance width in 16.16 fixed-point format. */
99+ /* */
100+ /* <Fields> */
101+ /* library :: A handle to the FreeType library object. */
102+ /* */
103+ /* clazz :: A pointer to the glyph's class. Private. */
104+ /* */
105+ /* format :: The format of the glyph's image. */
106+ /* */
107+ /* advance :: A 16.16 vector that gives the glyph's advance width. */
108+ /* */
109+ typedef struct FT_GlyphRec_
110+ {
111+ FT_Library library;
112+ const FT_Glyph_Class* clazz;
113+ FT_Glyph_Format format;
114+ FT_Vector advance;
115+
116+ } FT_GlyphRec;
117+
118+
119+ /*************************************************************************/
120+ /* */
121+ /* <Type> */
122+ /* FT_BitmapGlyph */
123+ /* */
124+ /* <Description> */
125+ /* A handle to an object used to model a bitmap glyph image. This is */
126+ /* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */
127+ /* */
128+ typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph;
129+
130+
131+ /*************************************************************************/
132+ /* */
133+ /* <Struct> */
134+ /* FT_BitmapGlyphRec */
135+ /* */
136+ /* <Description> */
137+ /* A structure used for bitmap glyph images. This really is a */
138+ /* `sub-class' of @FT_GlyphRec. */
139+ /* */
140+ /* <Fields> */
141+ /* root :: The root @FT_Glyph fields. */
142+ /* */
143+ /* left :: The left-side bearing, i.e., the horizontal distance */
144+ /* from the current pen position to the left border of the */
145+ /* glyph bitmap. */
146+ /* */
147+ /* top :: The top-side bearing, i.e., the vertical distance from */
148+ /* the current pen position to the top border of the glyph */
149+ /* bitmap. This distance is positive for upwards~y! */
150+ /* */
151+ /* bitmap :: A descriptor for the bitmap. */
152+ /* */
153+ /* <Note> */
154+ /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */
155+ /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */
156+ /* the bitmap's contents easily. */
157+ /* */
158+ /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */
159+ /* and is thus created and destroyed with it. */
160+ /* */
161+ typedef struct FT_BitmapGlyphRec_
162+ {
163+ FT_GlyphRec root;
164+ FT_Int left;
165+ FT_Int top;
166+ FT_Bitmap bitmap;
167+
168+ } FT_BitmapGlyphRec;
169+
170+
171+ /*************************************************************************/
172+ /* */
173+ /* <Type> */
174+ /* FT_OutlineGlyph */
175+ /* */
176+ /* <Description> */
177+ /* A handle to an object used to model an outline glyph image. This */
178+ /* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */
179+ /* */
180+ typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph;
181+
182+
183+ /*************************************************************************/
184+ /* */
185+ /* <Struct> */
186+ /* FT_OutlineGlyphRec */
187+ /* */
188+ /* <Description> */
189+ /* A structure used for outline (vectorial) glyph images. This */
190+ /* really is a `sub-class' of @FT_GlyphRec. */
191+ /* */
192+ /* <Fields> */
193+ /* root :: The root @FT_Glyph fields. */
194+ /* */
195+ /* outline :: A descriptor for the outline. */
196+ /* */
197+ /* <Note> */
198+ /* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */
199+ /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */
200+ /* the outline's content easily. */
201+ /* */
202+ /* As the outline is extracted from a glyph slot, its coordinates are */
203+ /* expressed normally in 26.6 pixels, unless the flag */
204+ /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */
205+ /* */
206+ /* The outline's tables are always owned by the object and are */
207+ /* destroyed with it. */
208+ /* */
209+ typedef struct FT_OutlineGlyphRec_
210+ {
211+ FT_GlyphRec root;
212+ FT_Outline outline;
213+
214+ } FT_OutlineGlyphRec;
215+
216+
217+ /*************************************************************************/
218+ /* */
219+ /* <Function> */
220+ /* FT_Get_Glyph */
221+ /* */
222+ /* <Description> */
223+ /* A function used to extract a glyph image from a slot. Note that */
224+ /* the created @FT_Glyph object must be released with @FT_Done_Glyph. */
225+ /* */
226+ /* <Input> */
227+ /* slot :: A handle to the source glyph slot. */
228+ /* */
229+ /* <Output> */
230+ /* aglyph :: A handle to the glyph object. */
231+ /* */
232+ /* <Return> */
233+ /* FreeType error code. 0~means success. */
234+ /* */
235+ /* <Note> */
236+ /* Because `*aglyph->advance.x' and '*aglyph->advance.y' are 16.16 */
237+ /* fixed-point numbers, `slot->advance.x' and `slot->advance.y' */
238+ /* (which are in 26.6 fixed-point format) must be in the range */
239+ /* ]-32768;32768[. */
240+ /* */
241+ FT_EXPORT( FT_Error )
242+ FT_Get_Glyph( FT_GlyphSlot slot,
243+ FT_Glyph *aglyph );
244+
245+
246+ /*************************************************************************/
247+ /* */
248+ /* <Function> */
249+ /* FT_Glyph_Copy */
250+ /* */
251+ /* <Description> */
252+ /* A function used to copy a glyph image. Note that the created */
253+ /* @FT_Glyph object must be released with @FT_Done_Glyph. */
254+ /* */
255+ /* <Input> */
256+ /* source :: A handle to the source glyph object. */
257+ /* */
258+ /* <Output> */
259+ /* target :: A handle to the target glyph object. 0~in case of */
260+ /* error. */
261+ /* */
262+ /* <Return> */
263+ /* FreeType error code. 0~means success. */
264+ /* */
265+ FT_EXPORT( FT_Error )
266+ FT_Glyph_Copy( FT_Glyph source,
267+ FT_Glyph *target );
268+
269+
270+ /*************************************************************************/
271+ /* */
272+ /* <Function> */
273+ /* FT_Glyph_Transform */
274+ /* */
275+ /* <Description> */
276+ /* Transform a glyph image if its format is scalable. */
277+ /* */
278+ /* <InOut> */
279+ /* glyph :: A handle to the target glyph object. */
280+ /* */
281+ /* <Input> */
282+ /* matrix :: A pointer to a 2x2 matrix to apply. */
283+ /* */
284+ /* delta :: A pointer to a 2d vector to apply. Coordinates are */
285+ /* expressed in 1/64th of a pixel. */
286+ /* */
287+ /* <Return> */
288+ /* FreeType error code (if not 0, the glyph format is not scalable). */
289+ /* */
290+ /* <Note> */
291+ /* The 2x2 transformation matrix is also applied to the glyph's */
292+ /* advance vector. */
293+ /* */
294+ FT_EXPORT( FT_Error )
295+ FT_Glyph_Transform( FT_Glyph glyph,
296+ FT_Matrix* matrix,
297+ FT_Vector* delta );
298+
299+
300+ /*************************************************************************/
301+ /* */
302+ /* <Enum> */
303+ /* FT_Glyph_BBox_Mode */
304+ /* */
305+ /* <Description> */
306+ /* The mode how the values of @FT_Glyph_Get_CBox are returned. */
307+ /* */
308+ /* <Values> */
309+ /* FT_GLYPH_BBOX_UNSCALED :: */
310+ /* Return unscaled font units. */
311+ /* */
312+ /* FT_GLYPH_BBOX_SUBPIXELS :: */
313+ /* Return unfitted 26.6 coordinates. */
314+ /* */
315+ /* FT_GLYPH_BBOX_GRIDFIT :: */
316+ /* Return grid-fitted 26.6 coordinates. */
317+ /* */
318+ /* FT_GLYPH_BBOX_TRUNCATE :: */
319+ /* Return coordinates in integer pixels. */
320+ /* */
321+ /* FT_GLYPH_BBOX_PIXELS :: */
322+ /* Return grid-fitted pixel coordinates. */
323+ /* */
324+ typedef enum FT_Glyph_BBox_Mode_
325+ {
326+ FT_GLYPH_BBOX_UNSCALED = 0,
327+ FT_GLYPH_BBOX_SUBPIXELS = 0,
328+ FT_GLYPH_BBOX_GRIDFIT = 1,
329+ FT_GLYPH_BBOX_TRUNCATE = 2,
330+ FT_GLYPH_BBOX_PIXELS = 3
331+
332+ } FT_Glyph_BBox_Mode;
333+
334+
335+ /* these constants are deprecated; use the corresponding */
336+ /* `FT_Glyph_BBox_Mode' values instead */
337+#define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED
338+#define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS
339+#define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT
340+#define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE
341+#define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS
342+
343+
344+ /*************************************************************************/
345+ /* */
346+ /* <Function> */
347+ /* FT_Glyph_Get_CBox */
348+ /* */
349+ /* <Description> */
350+ /* Return a glyph's `control box'. The control box encloses all the */
351+ /* outline's points, including Bezier control points. Though it */
352+ /* coincides with the exact bounding box for most glyphs, it can be */
353+ /* slightly larger in some situations (like when rotating an outline */
354+ /* that contains Bezier outside arcs). */
355+ /* */
356+ /* Computing the control box is very fast, while getting the bounding */
357+ /* box can take much more time as it needs to walk over all segments */
358+ /* and arcs in the outline. To get the latter, you can use the */
359+ /* `ftbbox' component, which is dedicated to this single task. */
360+ /* */
361+ /* <Input> */
362+ /* glyph :: A handle to the source glyph object. */
363+ /* */
364+ /* mode :: The mode that indicates how to interpret the returned */
365+ /* bounding box values. */
366+ /* */
367+ /* <Output> */
368+ /* acbox :: The glyph coordinate bounding box. Coordinates are */
369+ /* expressed in 1/64th of pixels if it is grid-fitted. */
370+ /* */
371+ /* <Note> */
372+ /* Coordinates are relative to the glyph origin, using the y~upwards */
373+ /* convention. */
374+ /* */
375+ /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */
376+ /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */
377+ /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */
378+ /* is another name for this constant. */
379+ /* */
380+ /* If the font is tricky and the glyph has been loaded with */
381+ /* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */
382+ /* reasonable values for the CBox it is necessary to load the glyph */
383+ /* at a large ppem value (so that the hinting instructions can */
384+ /* properly shift and scale the subglyphs), then extracting the CBox, */
385+ /* which can be eventually converted back to font units. */
386+ /* */
387+ /* Note that the maximum coordinates are exclusive, which means that */
388+ /* one can compute the width and height of the glyph image (be it in */
389+ /* integer or 26.6 pixels) as: */
390+ /* */
391+ /* { */
392+ /* width = bbox.xMax - bbox.xMin; */
393+ /* height = bbox.yMax - bbox.yMin; */
394+ /* } */
395+ /* */
396+ /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */
397+ /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */
398+ /* which corresponds to: */
399+ /* */
400+ /* { */
401+ /* bbox.xMin = FLOOR(bbox.xMin); */
402+ /* bbox.yMin = FLOOR(bbox.yMin); */
403+ /* bbox.xMax = CEILING(bbox.xMax); */
404+ /* bbox.yMax = CEILING(bbox.yMax); */
405+ /* } */
406+ /* */
407+ /* To get the bbox in pixel coordinates, set `bbox_mode' to */
408+ /* @FT_GLYPH_BBOX_TRUNCATE. */
409+ /* */
410+ /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */
411+ /* to @FT_GLYPH_BBOX_PIXELS. */
412+ /* */
413+ FT_EXPORT( void )
414+ FT_Glyph_Get_CBox( FT_Glyph glyph,
415+ FT_UInt bbox_mode,
416+ FT_BBox *acbox );
417+
418+
419+ /*************************************************************************/
420+ /* */
421+ /* <Function> */
422+ /* FT_Glyph_To_Bitmap */
423+ /* */
424+ /* <Description> */
425+ /* Convert a given glyph object to a bitmap glyph object. */
426+ /* */
427+ /* <InOut> */
428+ /* the_glyph :: A pointer to a handle to the target glyph. */
429+ /* */
430+ /* <Input> */
431+ /* render_mode :: An enumeration that describes how the data is */
432+ /* rendered. */
433+ /* */
434+ /* origin :: A pointer to a vector used to translate the glyph */
435+ /* image before rendering. Can be~0 (if no */
436+ /* translation). The origin is expressed in */
437+ /* 26.6 pixels. */
438+ /* */
439+ /* destroy :: A boolean that indicates that the original glyph */
440+ /* image should be destroyed by this function. It is */
441+ /* never destroyed in case of error. */
442+ /* */
443+ /* <Return> */
444+ /* FreeType error code. 0~means success. */
445+ /* */
446+ /* <Note> */
447+ /* This function does nothing if the glyph format isn't scalable. */
448+ /* */
449+ /* The glyph image is translated with the `origin' vector before */
450+ /* rendering. */
451+ /* */
452+ /* The first parameter is a pointer to an @FT_Glyph handle, that will */
453+ /* be _replaced_ by this function (with newly allocated data). */
454+ /* Typically, you would use (omitting error handling): */
455+ /* */
456+ /* */
457+ /* { */
458+ /* FT_Glyph glyph; */
459+ /* FT_BitmapGlyph glyph_bitmap; */
460+ /* */
461+ /* */
462+ /* // load glyph */
463+ /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); */
464+ /* */
465+ /* // extract glyph image */
466+ /* error = FT_Get_Glyph( face->glyph, &glyph ); */
467+ /* */
468+ /* // convert to a bitmap (default render mode + destroying old) */
469+ /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */
470+ /* { */
471+ /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */
472+ /* 0, 1 ); */
473+ /* if ( error ) // `glyph' unchanged */
474+ /* ... */
475+ /* } */
476+ /* */
477+ /* // access bitmap content by typecasting */
478+ /* glyph_bitmap = (FT_BitmapGlyph)glyph; */
479+ /* */
480+ /* // do funny stuff with it, like blitting/drawing */
481+ /* ... */
482+ /* */
483+ /* // discard glyph image (bitmap or not) */
484+ /* FT_Done_Glyph( glyph ); */
485+ /* } */
486+ /* */
487+ /* */
488+ /* Here another example, again without error handling: */
489+ /* */
490+ /* */
491+ /* { */
492+ /* FT_Glyph glyphs[MAX_GLYPHS] */
493+ /* */
494+ /* */
495+ /* ... */
496+ /* */
497+ /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
498+ /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */
499+ /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */
500+ /* */
501+ /* ... */
502+ /* */
503+ /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
504+ /* { */
505+ /* FT_Glyph bitmap = glyphs[idx]; */
506+ /* */
507+ /* */
508+ /* ... */
509+ /* */
510+ /* // after this call, `bitmap' no longer points into */
511+ /* // the `glyphs' array (and the old value isn't destroyed) */
512+ /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */
513+ /* */
514+ /* ... */
515+ /* */
516+ /* FT_Done_Glyph( bitmap ); */
517+ /* } */
518+ /* */
519+ /* ... */
520+ /* */
521+ /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
522+ /* FT_Done_Glyph( glyphs[idx] ); */
523+ /* } */
524+ /* */
525+ FT_EXPORT( FT_Error )
526+ FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
527+ FT_Render_Mode render_mode,
528+ FT_Vector* origin,
529+ FT_Bool destroy );
530+
531+
532+ /*************************************************************************/
533+ /* */
534+ /* <Function> */
535+ /* FT_Done_Glyph */
536+ /* */
537+ /* <Description> */
538+ /* Destroy a given glyph. */
539+ /* */
540+ /* <Input> */
541+ /* glyph :: A handle to the target glyph object. */
542+ /* */
543+ FT_EXPORT( void )
544+ FT_Done_Glyph( FT_Glyph glyph );
545+
546+ /* */
547+
548+
549+ /* other helpful functions */
550+
551+ /*************************************************************************/
552+ /* */
553+ /* <Section> */
554+ /* computations */
555+ /* */
556+ /*************************************************************************/
557+
558+
559+ /*************************************************************************/
560+ /* */
561+ /* <Function> */
562+ /* FT_Matrix_Multiply */
563+ /* */
564+ /* <Description> */
565+ /* Perform the matrix operation `b = a*b'. */
566+ /* */
567+ /* <Input> */
568+ /* a :: A pointer to matrix `a'. */
569+ /* */
570+ /* <InOut> */
571+ /* b :: A pointer to matrix `b'. */
572+ /* */
573+ /* <Note> */
574+ /* The result is undefined if either `a' or `b' is zero. */
575+ /* */
576+ /* Since the function uses wrap-around arithmetic, results become */
577+ /* meaningless if the arguments are very large. */
578+ /* */
579+ FT_EXPORT( void )
580+ FT_Matrix_Multiply( const FT_Matrix* a,
581+ FT_Matrix* b );
582+
583+
584+ /*************************************************************************/
585+ /* */
586+ /* <Function> */
587+ /* FT_Matrix_Invert */
588+ /* */
589+ /* <Description> */
590+ /* Invert a 2x2 matrix. Return an error if it can't be inverted. */
591+ /* */
592+ /* <InOut> */
593+ /* matrix :: A pointer to the target matrix. Remains untouched in */
594+ /* case of error. */
595+ /* */
596+ /* <Return> */
597+ /* FreeType error code. 0~means success. */
598+ /* */
599+ FT_EXPORT( FT_Error )
600+ FT_Matrix_Invert( FT_Matrix* matrix );
601+
602+ /* */
603+
604+
605+FT_END_HEADER
606+
607+#endif /* FTGLYPH_H_ */
608+
609+
610+/* END */
611+
612+
613+/* Local Variables: */
614+/* coding: utf-8 */
615+/* End: */
1@@ -0,0 +1,357 @@
2+/***************************************************************************/
3+/* */
4+/* ftgxval.h */
5+/* */
6+/* FreeType API for validating TrueTypeGX/AAT tables (specification). */
7+/* */
8+/* Copyright 2004-2018 by */
9+/* Masatake YAMATO, Redhat K.K, */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+/***************************************************************************/
21+/* */
22+/* gxvalid is derived from both gxlayout module and otvalid module. */
23+/* Development of gxlayout is supported by the Information-technology */
24+/* Promotion Agency(IPA), Japan. */
25+/* */
26+/***************************************************************************/
27+
28+
29+#ifndef FTGXVAL_H_
30+#define FTGXVAL_H_
31+
32+#include <ft2build.h>
33+#include FT_FREETYPE_H
34+
35+#ifdef FREETYPE_H
36+#error "freetype.h of FreeType 1 has been loaded!"
37+#error "Please fix the directory search order for header files"
38+#error "so that freetype.h of FreeType 2 is found first."
39+#endif
40+
41+
42+FT_BEGIN_HEADER
43+
44+
45+ /*************************************************************************/
46+ /* */
47+ /* <Section> */
48+ /* gx_validation */
49+ /* */
50+ /* <Title> */
51+ /* TrueTypeGX/AAT Validation */
52+ /* */
53+ /* <Abstract> */
54+ /* An API to validate TrueTypeGX/AAT tables. */
55+ /* */
56+ /* <Description> */
57+ /* This section contains the declaration of functions to validate */
58+ /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */
59+ /* trak, prop, lcar). */
60+ /* */
61+ /* <Order> */
62+ /* FT_TrueTypeGX_Validate */
63+ /* FT_TrueTypeGX_Free */
64+ /* */
65+ /* FT_ClassicKern_Validate */
66+ /* FT_ClassicKern_Free */
67+ /* */
68+ /* FT_VALIDATE_GX_LENGTH */
69+ /* FT_VALIDATE_GXXXX */
70+ /* FT_VALIDATE_CKERNXXX */
71+ /* */
72+ /*************************************************************************/
73+
74+ /*************************************************************************/
75+ /* */
76+ /* */
77+ /* Warning: Use FT_VALIDATE_XXX to validate a table. */
78+ /* Following definitions are for gxvalid developers. */
79+ /* */
80+ /* */
81+ /*************************************************************************/
82+
83+#define FT_VALIDATE_feat_INDEX 0
84+#define FT_VALIDATE_mort_INDEX 1
85+#define FT_VALIDATE_morx_INDEX 2
86+#define FT_VALIDATE_bsln_INDEX 3
87+#define FT_VALIDATE_just_INDEX 4
88+#define FT_VALIDATE_kern_INDEX 5
89+#define FT_VALIDATE_opbd_INDEX 6
90+#define FT_VALIDATE_trak_INDEX 7
91+#define FT_VALIDATE_prop_INDEX 8
92+#define FT_VALIDATE_lcar_INDEX 9
93+#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX
94+
95+
96+ /*************************************************************************
97+ *
98+ * @macro:
99+ * FT_VALIDATE_GX_LENGTH
100+ *
101+ * @description:
102+ * The number of tables checked in this module. Use it as a parameter
103+ * for the `table-length' argument of function @FT_TrueTypeGX_Validate.
104+ */
105+#define FT_VALIDATE_GX_LENGTH ( FT_VALIDATE_GX_LAST_INDEX + 1 )
106+
107+ /* */
108+
109+ /* Up to 0x1000 is used by otvalid.
110+ Ox2xxx is reserved for feature OT extension. */
111+#define FT_VALIDATE_GX_START 0x4000
112+#define FT_VALIDATE_GX_BITFIELD( tag ) \
113+ ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX )
114+
115+
116+ /**********************************************************************
117+ *
118+ * @enum:
119+ * FT_VALIDATE_GXXXX
120+ *
121+ * @description:
122+ * A list of bit-field constants used with @FT_TrueTypeGX_Validate to
123+ * indicate which TrueTypeGX/AAT Type tables should be validated.
124+ *
125+ * @values:
126+ * FT_VALIDATE_feat ::
127+ * Validate `feat' table.
128+ *
129+ * FT_VALIDATE_mort ::
130+ * Validate `mort' table.
131+ *
132+ * FT_VALIDATE_morx ::
133+ * Validate `morx' table.
134+ *
135+ * FT_VALIDATE_bsln ::
136+ * Validate `bsln' table.
137+ *
138+ * FT_VALIDATE_just ::
139+ * Validate `just' table.
140+ *
141+ * FT_VALIDATE_kern ::
142+ * Validate `kern' table.
143+ *
144+ * FT_VALIDATE_opbd ::
145+ * Validate `opbd' table.
146+ *
147+ * FT_VALIDATE_trak ::
148+ * Validate `trak' table.
149+ *
150+ * FT_VALIDATE_prop ::
151+ * Validate `prop' table.
152+ *
153+ * FT_VALIDATE_lcar ::
154+ * Validate `lcar' table.
155+ *
156+ * FT_VALIDATE_GX ::
157+ * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern,
158+ * opbd, trak, prop and lcar).
159+ *
160+ */
161+
162+#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat )
163+#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort )
164+#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx )
165+#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln )
166+#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just )
167+#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern )
168+#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd )
169+#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak )
170+#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop )
171+#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar )
172+
173+#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \
174+ FT_VALIDATE_mort | \
175+ FT_VALIDATE_morx | \
176+ FT_VALIDATE_bsln | \
177+ FT_VALIDATE_just | \
178+ FT_VALIDATE_kern | \
179+ FT_VALIDATE_opbd | \
180+ FT_VALIDATE_trak | \
181+ FT_VALIDATE_prop | \
182+ FT_VALIDATE_lcar )
183+
184+
185+ /**********************************************************************
186+ *
187+ * @function:
188+ * FT_TrueTypeGX_Validate
189+ *
190+ * @description:
191+ * Validate various TrueTypeGX tables to assure that all offsets and
192+ * indices are valid. The idea is that a higher-level library that
193+ * actually does the text layout can access those tables without
194+ * error checking (which can be quite time consuming).
195+ *
196+ * @input:
197+ * face ::
198+ * A handle to the input face.
199+ *
200+ * validation_flags ::
201+ * A bit field that specifies the tables to be validated. See
202+ * @FT_VALIDATE_GXXXX for possible values.
203+ *
204+ * table_length ::
205+ * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH
206+ * should be passed.
207+ *
208+ * @output:
209+ * tables ::
210+ * The array where all validated sfnt tables are stored.
211+ * The array itself must be allocated by a client.
212+ *
213+ * @return:
214+ * FreeType error code. 0~means success.
215+ *
216+ * @note:
217+ * This function only works with TrueTypeGX fonts, returning an error
218+ * otherwise.
219+ *
220+ * After use, the application should deallocate the buffers pointed to by
221+ * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value
222+ * indicates that the table either doesn't exist in the font, the
223+ * application hasn't asked for validation, or the validator doesn't have
224+ * the ability to validate the sfnt table.
225+ */
226+ FT_EXPORT( FT_Error )
227+ FT_TrueTypeGX_Validate( FT_Face face,
228+ FT_UInt validation_flags,
229+ FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
230+ FT_UInt table_length );
231+
232+
233+ /**********************************************************************
234+ *
235+ * @function:
236+ * FT_TrueTypeGX_Free
237+ *
238+ * @description:
239+ * Free the buffer allocated by TrueTypeGX validator.
240+ *
241+ * @input:
242+ * face ::
243+ * A handle to the input face.
244+ *
245+ * table ::
246+ * The pointer to the buffer allocated by
247+ * @FT_TrueTypeGX_Validate.
248+ *
249+ * @note:
250+ * This function must be used to free the buffer allocated by
251+ * @FT_TrueTypeGX_Validate only.
252+ */
253+ FT_EXPORT( void )
254+ FT_TrueTypeGX_Free( FT_Face face,
255+ FT_Bytes table );
256+
257+
258+ /**********************************************************************
259+ *
260+ * @enum:
261+ * FT_VALIDATE_CKERNXXX
262+ *
263+ * @description:
264+ * A list of bit-field constants used with @FT_ClassicKern_Validate
265+ * to indicate the classic kern dialect or dialects. If the selected
266+ * type doesn't fit, @FT_ClassicKern_Validate regards the table as
267+ * invalid.
268+ *
269+ * @values:
270+ * FT_VALIDATE_MS ::
271+ * Handle the `kern' table as a classic Microsoft kern table.
272+ *
273+ * FT_VALIDATE_APPLE ::
274+ * Handle the `kern' table as a classic Apple kern table.
275+ *
276+ * FT_VALIDATE_CKERN ::
277+ * Handle the `kern' as either classic Apple or Microsoft kern table.
278+ */
279+#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 )
280+#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 )
281+
282+#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE )
283+
284+
285+ /**********************************************************************
286+ *
287+ * @function:
288+ * FT_ClassicKern_Validate
289+ *
290+ * @description:
291+ * Validate classic (16-bit format) kern table to assure that the offsets
292+ * and indices are valid. The idea is that a higher-level library that
293+ * actually does the text layout can access those tables without error
294+ * checking (which can be quite time consuming).
295+ *
296+ * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both
297+ * the new 32-bit format and the classic 16-bit format, while
298+ * FT_ClassicKern_Validate only supports the classic 16-bit format.
299+ *
300+ * @input:
301+ * face ::
302+ * A handle to the input face.
303+ *
304+ * validation_flags ::
305+ * A bit field that specifies the dialect to be validated. See
306+ * @FT_VALIDATE_CKERNXXX for possible values.
307+ *
308+ * @output:
309+ * ckern_table ::
310+ * A pointer to the kern table.
311+ *
312+ * @return:
313+ * FreeType error code. 0~means success.
314+ *
315+ * @note:
316+ * After use, the application should deallocate the buffers pointed to by
317+ * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value
318+ * indicates that the table doesn't exist in the font.
319+ */
320+ FT_EXPORT( FT_Error )
321+ FT_ClassicKern_Validate( FT_Face face,
322+ FT_UInt validation_flags,
323+ FT_Bytes *ckern_table );
324+
325+
326+ /**********************************************************************
327+ *
328+ * @function:
329+ * FT_ClassicKern_Free
330+ *
331+ * @description:
332+ * Free the buffer allocated by classic Kern validator.
333+ *
334+ * @input:
335+ * face ::
336+ * A handle to the input face.
337+ *
338+ * table ::
339+ * The pointer to the buffer that is allocated by
340+ * @FT_ClassicKern_Validate.
341+ *
342+ * @note:
343+ * This function must be used to free the buffer allocated by
344+ * @FT_ClassicKern_Validate only.
345+ */
346+ FT_EXPORT( void )
347+ FT_ClassicKern_Free( FT_Face face,
348+ FT_Bytes table );
349+
350+ /* */
351+
352+
353+FT_END_HEADER
354+
355+#endif /* FTGXVAL_H_ */
356+
357+
358+/* END */
1@@ -0,0 +1,151 @@
2+/***************************************************************************/
3+/* */
4+/* ftgzip.h */
5+/* */
6+/* Gzip-compressed stream support. */
7+/* */
8+/* Copyright 2002-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTGZIP_H_
21+#define FTGZIP_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+ /*************************************************************************/
36+ /* */
37+ /* <Section> */
38+ /* gzip */
39+ /* */
40+ /* <Title> */
41+ /* GZIP Streams */
42+ /* */
43+ /* <Abstract> */
44+ /* Using gzip-compressed font files. */
45+ /* */
46+ /* <Description> */
47+ /* This section contains the declaration of Gzip-specific functions. */
48+ /* */
49+ /*************************************************************************/
50+
51+
52+ /************************************************************************
53+ *
54+ * @function:
55+ * FT_Stream_OpenGzip
56+ *
57+ * @description:
58+ * Open a new stream to parse gzip-compressed font files. This is
59+ * mainly used to support the compressed `*.pcf.gz' fonts that come
60+ * with XFree86.
61+ *
62+ * @input:
63+ * stream ::
64+ * The target embedding stream.
65+ *
66+ * source ::
67+ * The source stream.
68+ *
69+ * @return:
70+ * FreeType error code. 0~means success.
71+ *
72+ * @note:
73+ * The source stream must be opened _before_ calling this function.
74+ *
75+ * Calling the internal function `FT_Stream_Close' on the new stream will
76+ * *not* call `FT_Stream_Close' on the source stream. None of the stream
77+ * objects will be released to the heap.
78+ *
79+ * The stream implementation is very basic and resets the decompression
80+ * process each time seeking backwards is needed within the stream.
81+ *
82+ * In certain builds of the library, gzip compression recognition is
83+ * automatically handled when calling @FT_New_Face or @FT_Open_Face.
84+ * This means that if no font driver is capable of handling the raw
85+ * compressed file, the library will try to open a gzipped stream from
86+ * it and re-open the face with it.
87+ *
88+ * This function may return `FT_Err_Unimplemented_Feature' if your build
89+ * of FreeType was not compiled with zlib support.
90+ */
91+ FT_EXPORT( FT_Error )
92+ FT_Stream_OpenGzip( FT_Stream stream,
93+ FT_Stream source );
94+
95+
96+ /************************************************************************
97+ *
98+ * @function:
99+ * FT_Gzip_Uncompress
100+ *
101+ * @description:
102+ * Decompress a zipped input buffer into an output buffer. This function
103+ * is modeled after zlib's `uncompress' function.
104+ *
105+ * @input:
106+ * memory ::
107+ * A FreeType memory handle.
108+ *
109+ * input ::
110+ * The input buffer.
111+ *
112+ * input_len ::
113+ * The length of the input buffer.
114+ *
115+ * @output:
116+ * output::
117+ * The output buffer.
118+ *
119+ * @inout:
120+ * output_len ::
121+ * Before calling the function, this is the total size of the output
122+ * buffer, which must be large enough to hold the entire uncompressed
123+ * data (so the size of the uncompressed data must be known in
124+ * advance). After calling the function, `output_len' is the size of
125+ * the used data in `output'.
126+ *
127+ * @return:
128+ * FreeType error code. 0~means success.
129+ *
130+ * @note:
131+ * This function may return `FT_Err_Unimplemented_Feature' if your build
132+ * of FreeType was not compiled with zlib support.
133+ *
134+ * @since:
135+ * 2.5.1
136+ */
137+ FT_EXPORT( FT_Error )
138+ FT_Gzip_Uncompress( FT_Memory memory,
139+ FT_Byte* output,
140+ FT_ULong* output_len,
141+ const FT_Byte* input,
142+ FT_ULong input_len );
143+
144+ /* */
145+
146+
147+FT_END_HEADER
148+
149+#endif /* FTGZIP_H_ */
150+
151+
152+/* END */
+1205,
-0
1@@ -0,0 +1,1205 @@
2+/***************************************************************************/
3+/* */
4+/* ftimage.h */
5+/* */
6+/* FreeType glyph image formats and default raster interface */
7+/* (specification). */
8+/* */
9+/* Copyright 1996-2018 by */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+ /*************************************************************************/
21+ /* */
22+ /* Note: A `raster' is simply a scan-line converter, used to render */
23+ /* FT_Outlines into FT_Bitmaps. */
24+ /* */
25+ /*************************************************************************/
26+
27+
28+#ifndef FTIMAGE_H_
29+#define FTIMAGE_H_
30+
31+
32+ /* STANDALONE_ is from ftgrays.c */
33+#ifndef STANDALONE_
34+#include <ft2build.h>
35+#endif
36+
37+
38+FT_BEGIN_HEADER
39+
40+
41+ /*************************************************************************/
42+ /* */
43+ /* <Section> */
44+ /* basic_types */
45+ /* */
46+ /*************************************************************************/
47+
48+
49+ /*************************************************************************/
50+ /* */
51+ /* <Type> */
52+ /* FT_Pos */
53+ /* */
54+ /* <Description> */
55+ /* The type FT_Pos is used to store vectorial coordinates. Depending */
56+ /* on the context, these can represent distances in integer font */
57+ /* units, or 16.16, or 26.6 fixed-point pixel coordinates. */
58+ /* */
59+ typedef signed long FT_Pos;
60+
61+
62+ /*************************************************************************/
63+ /* */
64+ /* <Struct> */
65+ /* FT_Vector */
66+ /* */
67+ /* <Description> */
68+ /* A simple structure used to store a 2D vector; coordinates are of */
69+ /* the FT_Pos type. */
70+ /* */
71+ /* <Fields> */
72+ /* x :: The horizontal coordinate. */
73+ /* y :: The vertical coordinate. */
74+ /* */
75+ typedef struct FT_Vector_
76+ {
77+ FT_Pos x;
78+ FT_Pos y;
79+
80+ } FT_Vector;
81+
82+
83+ /*************************************************************************/
84+ /* */
85+ /* <Struct> */
86+ /* FT_BBox */
87+ /* */
88+ /* <Description> */
89+ /* A structure used to hold an outline's bounding box, i.e., the */
90+ /* coordinates of its extrema in the horizontal and vertical */
91+ /* directions. */
92+ /* */
93+ /* <Fields> */
94+ /* xMin :: The horizontal minimum (left-most). */
95+ /* */
96+ /* yMin :: The vertical minimum (bottom-most). */
97+ /* */
98+ /* xMax :: The horizontal maximum (right-most). */
99+ /* */
100+ /* yMax :: The vertical maximum (top-most). */
101+ /* */
102+ /* <Note> */
103+ /* The bounding box is specified with the coordinates of the lower */
104+ /* left and the upper right corner. In PostScript, those values are */
105+ /* often called (llx,lly) and (urx,ury), respectively. */
106+ /* */
107+ /* If `yMin' is negative, this value gives the glyph's descender. */
108+ /* Otherwise, the glyph doesn't descend below the baseline. */
109+ /* Similarly, if `ymax' is positive, this value gives the glyph's */
110+ /* ascender. */
111+ /* */
112+ /* `xMin' gives the horizontal distance from the glyph's origin to */
113+ /* the left edge of the glyph's bounding box. If `xMin' is negative, */
114+ /* the glyph extends to the left of the origin. */
115+ /* */
116+ typedef struct FT_BBox_
117+ {
118+ FT_Pos xMin, yMin;
119+ FT_Pos xMax, yMax;
120+
121+ } FT_BBox;
122+
123+
124+ /*************************************************************************/
125+ /* */
126+ /* <Enum> */
127+ /* FT_Pixel_Mode */
128+ /* */
129+ /* <Description> */
130+ /* An enumeration type used to describe the format of pixels in a */
131+ /* given bitmap. Note that additional formats may be added in the */
132+ /* future. */
133+ /* */
134+ /* <Values> */
135+ /* FT_PIXEL_MODE_NONE :: */
136+ /* Value~0 is reserved. */
137+ /* */
138+ /* FT_PIXEL_MODE_MONO :: */
139+ /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */
140+ /* are stored in most-significant order (MSB), which means that */
141+ /* the left-most pixel in a byte has value 128. */
142+ /* */
143+ /* FT_PIXEL_MODE_GRAY :: */
144+ /* An 8-bit bitmap, generally used to represent anti-aliased glyph */
145+ /* images. Each pixel is stored in one byte. Note that the number */
146+ /* of `gray' levels is stored in the `num_grays' field of the */
147+ /* @FT_Bitmap structure (it generally is 256). */
148+ /* */
149+ /* FT_PIXEL_MODE_GRAY2 :: */
150+ /* A 2-bit per pixel bitmap, used to represent embedded */
151+ /* anti-aliased bitmaps in font files according to the OpenType */
152+ /* specification. We haven't found a single font using this */
153+ /* format, however. */
154+ /* */
155+ /* FT_PIXEL_MODE_GRAY4 :: */
156+ /* A 4-bit per pixel bitmap, representing embedded anti-aliased */
157+ /* bitmaps in font files according to the OpenType specification. */
158+ /* We haven't found a single font using this format, however. */
159+ /* */
160+ /* FT_PIXEL_MODE_LCD :: */
161+ /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */
162+ /* used for display on LCD displays; the bitmap is three times */
163+ /* wider than the original glyph image. See also */
164+ /* @FT_RENDER_MODE_LCD. */
165+ /* */
166+ /* FT_PIXEL_MODE_LCD_V :: */
167+ /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */
168+ /* used for display on rotated LCD displays; the bitmap is three */
169+ /* times taller than the original glyph image. See also */
170+ /* @FT_RENDER_MODE_LCD_V. */
171+ /* */
172+ /* FT_PIXEL_MODE_BGRA :: */
173+ /* [Since 2.5] An image with four 8-bit channels per pixel, */
174+ /* representing a color image (such as emoticons) with alpha */
175+ /* channel. For each pixel, the format is BGRA, which means, the */
176+ /* blue channel comes first in memory. The color channels are */
177+ /* pre-multiplied and in the sRGB colorspace. For example, full */
178+ /* red at half-translucent opacity will be represented as */
179+ /* `00,00,80,80', not `00,00,FF,80'. See also @FT_LOAD_COLOR. */
180+ /* */
181+ typedef enum FT_Pixel_Mode_
182+ {
183+ FT_PIXEL_MODE_NONE = 0,
184+ FT_PIXEL_MODE_MONO,
185+ FT_PIXEL_MODE_GRAY,
186+ FT_PIXEL_MODE_GRAY2,
187+ FT_PIXEL_MODE_GRAY4,
188+ FT_PIXEL_MODE_LCD,
189+ FT_PIXEL_MODE_LCD_V,
190+ FT_PIXEL_MODE_BGRA,
191+
192+ FT_PIXEL_MODE_MAX /* do not remove */
193+
194+ } FT_Pixel_Mode;
195+
196+
197+ /* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */
198+ /* values instead. */
199+#define ft_pixel_mode_none FT_PIXEL_MODE_NONE
200+#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
201+#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
202+#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
203+#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
204+
205+
206+ /*************************************************************************/
207+ /* */
208+ /* <Struct> */
209+ /* FT_Bitmap */
210+ /* */
211+ /* <Description> */
212+ /* A structure used to describe a bitmap or pixmap to the raster. */
213+ /* Note that we now manage pixmaps of various depths through the */
214+ /* `pixel_mode' field. */
215+ /* */
216+ /* <Fields> */
217+ /* rows :: The number of bitmap rows. */
218+ /* */
219+ /* width :: The number of pixels in bitmap row. */
220+ /* */
221+ /* pitch :: The pitch's absolute value is the number of bytes */
222+ /* taken by one bitmap row, including padding. */
223+ /* However, the pitch is positive when the bitmap has */
224+ /* a `down' flow, and negative when it has an `up' */
225+ /* flow. In all cases, the pitch is an offset to add */
226+ /* to a bitmap pointer in order to go down one row. */
227+ /* */
228+ /* Note that `padding' means the alignment of a */
229+ /* bitmap to a byte border, and FreeType functions */
230+ /* normally align to the smallest possible integer */
231+ /* value. */
232+ /* */
233+ /* For the B/W rasterizer, `pitch' is always an even */
234+ /* number. */
235+ /* */
236+ /* To change the pitch of a bitmap (say, to make it a */
237+ /* multiple of 4), use @FT_Bitmap_Convert. */
238+ /* Alternatively, you might use callback functions to */
239+ /* directly render to the application's surface; see */
240+ /* the file `example2.cpp' in the tutorial for a */
241+ /* demonstration. */
242+ /* */
243+ /* buffer :: A typeless pointer to the bitmap buffer. This */
244+ /* value should be aligned on 32-bit boundaries in */
245+ /* most cases. */
246+ /* */
247+ /* num_grays :: This field is only used with */
248+ /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */
249+ /* levels used in the bitmap. */
250+ /* */
251+ /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
252+ /* See @FT_Pixel_Mode for possible values. */
253+ /* */
254+ /* palette_mode :: This field is intended for paletted pixel modes; */
255+ /* it indicates how the palette is stored. Not */
256+ /* used currently. */
257+ /* */
258+ /* palette :: A typeless pointer to the bitmap palette; this */
259+ /* field is intended for paletted pixel modes. Not */
260+ /* used currently. */
261+ /* */
262+ typedef struct FT_Bitmap_
263+ {
264+ unsigned int rows;
265+ unsigned int width;
266+ int pitch;
267+ unsigned char* buffer;
268+ unsigned short num_grays;
269+ unsigned char pixel_mode;
270+ unsigned char palette_mode;
271+ void* palette;
272+
273+ } FT_Bitmap;
274+
275+
276+ /*************************************************************************/
277+ /* */
278+ /* <Section> */
279+ /* outline_processing */
280+ /* */
281+ /*************************************************************************/
282+
283+
284+ /*************************************************************************/
285+ /* */
286+ /* <Struct> */
287+ /* FT_Outline */
288+ /* */
289+ /* <Description> */
290+ /* This structure is used to describe an outline to the scan-line */
291+ /* converter. */
292+ /* */
293+ /* <Fields> */
294+ /* n_contours :: The number of contours in the outline. */
295+ /* */
296+ /* n_points :: The number of points in the outline. */
297+ /* */
298+ /* points :: A pointer to an array of `n_points' @FT_Vector */
299+ /* elements, giving the outline's point coordinates. */
300+ /* */
301+ /* tags :: A pointer to an array of `n_points' chars, giving */
302+ /* each outline point's type. */
303+ /* */
304+ /* If bit~0 is unset, the point is `off' the curve, */
305+ /* i.e., a Bezier control point, while it is `on' if */
306+ /* set. */
307+ /* */
308+ /* Bit~1 is meaningful for `off' points only. If set, */
309+ /* it indicates a third-order Bezier arc control point; */
310+ /* and a second-order control point if unset. */
311+ /* */
312+ /* If bit~2 is set, bits 5-7 contain the drop-out mode */
313+ /* (as defined in the OpenType specification; the value */
314+ /* is the same as the argument to the SCANMODE */
315+ /* instruction). */
316+ /* */
317+ /* Bits 3 and~4 are reserved for internal purposes. */
318+ /* */
319+ /* contours :: An array of `n_contours' shorts, giving the end */
320+ /* point of each contour within the outline. For */
321+ /* example, the first contour is defined by the points */
322+ /* `0' to `contours[0]', the second one is defined by */
323+ /* the points `contours[0]+1' to `contours[1]', etc. */
324+ /* */
325+ /* flags :: A set of bit flags used to characterize the outline */
326+ /* and give hints to the scan-converter and hinter on */
327+ /* how to convert/grid-fit it. See @FT_OUTLINE_XXX. */
328+ /* */
329+ /* <Note> */
330+ /* The B/W rasterizer only checks bit~2 in the `tags' array for the */
331+ /* first point of each contour. The drop-out mode as given with */
332+ /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */
333+ /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */
334+ /* */
335+ typedef struct FT_Outline_
336+ {
337+ short n_contours; /* number of contours in glyph */
338+ short n_points; /* number of points in the glyph */
339+
340+ FT_Vector* points; /* the outline's points */
341+ char* tags; /* the points flags */
342+ short* contours; /* the contour end points */
343+
344+ int flags; /* outline masks */
345+
346+ } FT_Outline;
347+
348+ /* */
349+
350+ /* Following limits must be consistent with */
351+ /* FT_Outline.{n_contours,n_points} */
352+#define FT_OUTLINE_CONTOURS_MAX SHRT_MAX
353+#define FT_OUTLINE_POINTS_MAX SHRT_MAX
354+
355+
356+ /*************************************************************************/
357+ /* */
358+ /* <Enum> */
359+ /* FT_OUTLINE_XXX */
360+ /* */
361+ /* <Description> */
362+ /* A list of bit-field constants use for the flags in an outline's */
363+ /* `flags' field. */
364+ /* */
365+ /* <Values> */
366+ /* FT_OUTLINE_NONE :: */
367+ /* Value~0 is reserved. */
368+ /* */
369+ /* FT_OUTLINE_OWNER :: */
370+ /* If set, this flag indicates that the outline's field arrays */
371+ /* (i.e., `points', `flags', and `contours') are `owned' by the */
372+ /* outline object, and should thus be freed when it is destroyed. */
373+ /* */
374+ /* FT_OUTLINE_EVEN_ODD_FILL :: */
375+ /* By default, outlines are filled using the non-zero winding rule. */
376+ /* If set to 1, the outline will be filled using the even-odd fill */
377+ /* rule (only works with the smooth rasterizer). */
378+ /* */
379+ /* FT_OUTLINE_REVERSE_FILL :: */
380+ /* By default, outside contours of an outline are oriented in */
381+ /* clock-wise direction, as defined in the TrueType specification. */
382+ /* This flag is set if the outline uses the opposite direction */
383+ /* (typically for Type~1 fonts). This flag is ignored by the scan */
384+ /* converter. */
385+ /* */
386+ /* FT_OUTLINE_IGNORE_DROPOUTS :: */
387+ /* By default, the scan converter will try to detect drop-outs in */
388+ /* an outline and correct the glyph bitmap to ensure consistent */
389+ /* shape continuity. If set, this flag hints the scan-line */
390+ /* converter to ignore such cases. See below for more information. */
391+ /* */
392+ /* FT_OUTLINE_SMART_DROPOUTS :: */
393+ /* Select smart dropout control. If unset, use simple dropout */
394+ /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */
395+ /* below for more information. */
396+ /* */
397+ /* FT_OUTLINE_INCLUDE_STUBS :: */
398+ /* If set, turn pixels on for `stubs', otherwise exclude them. */
399+ /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */
400+ /* more information. */
401+ /* */
402+ /* FT_OUTLINE_HIGH_PRECISION :: */
403+ /* This flag indicates that the scan-line converter should try to */
404+ /* convert this outline to bitmaps with the highest possible */
405+ /* quality. It is typically set for small character sizes. Note */
406+ /* that this is only a hint that might be completely ignored by a */
407+ /* given scan-converter. */
408+ /* */
409+ /* FT_OUTLINE_SINGLE_PASS :: */
410+ /* This flag is set to force a given scan-converter to only use a */
411+ /* single pass over the outline to render a bitmap glyph image. */
412+ /* Normally, it is set for very large character sizes. It is only */
413+ /* a hint that might be completely ignored by a given */
414+ /* scan-converter. */
415+ /* */
416+ /* <Note> */
417+ /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */
418+ /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */
419+ /* rasterizer. */
420+ /* */
421+ /* There exists a second mechanism to pass the drop-out mode to the */
422+ /* B/W rasterizer; see the `tags' field in @FT_Outline. */
423+ /* */
424+ /* Please refer to the description of the `SCANTYPE' instruction in */
425+ /* the OpenType specification (in file `ttinst1.doc') how simple */
426+ /* drop-outs, smart drop-outs, and stubs are defined. */
427+ /* */
428+#define FT_OUTLINE_NONE 0x0
429+#define FT_OUTLINE_OWNER 0x1
430+#define FT_OUTLINE_EVEN_ODD_FILL 0x2
431+#define FT_OUTLINE_REVERSE_FILL 0x4
432+#define FT_OUTLINE_IGNORE_DROPOUTS 0x8
433+#define FT_OUTLINE_SMART_DROPOUTS 0x10
434+#define FT_OUTLINE_INCLUDE_STUBS 0x20
435+
436+#define FT_OUTLINE_HIGH_PRECISION 0x100
437+#define FT_OUTLINE_SINGLE_PASS 0x200
438+
439+
440+ /* these constants are deprecated; use the corresponding */
441+ /* `FT_OUTLINE_XXX' values instead */
442+#define ft_outline_none FT_OUTLINE_NONE
443+#define ft_outline_owner FT_OUTLINE_OWNER
444+#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
445+#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
446+#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
447+#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
448+#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
449+
450+ /* */
451+
452+#define FT_CURVE_TAG( flag ) ( flag & 3 )
453+
454+#define FT_CURVE_TAG_ON 1
455+#define FT_CURVE_TAG_CONIC 0
456+#define FT_CURVE_TAG_CUBIC 2
457+
458+#define FT_CURVE_TAG_HAS_SCANMODE 4
459+
460+#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
461+#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
462+
463+#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
464+ FT_CURVE_TAG_TOUCH_Y )
465+
466+#define FT_Curve_Tag_On FT_CURVE_TAG_ON
467+#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
468+#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
469+#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
470+#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
471+
472+
473+ /*************************************************************************/
474+ /* */
475+ /* <FuncType> */
476+ /* FT_Outline_MoveToFunc */
477+ /* */
478+ /* <Description> */
479+ /* A function pointer type used to describe the signature of a `move */
480+ /* to' function during outline walking/decomposition. */
481+ /* */
482+ /* A `move to' is emitted to start a new contour in an outline. */
483+ /* */
484+ /* <Input> */
485+ /* to :: A pointer to the target point of the `move to'. */
486+ /* */
487+ /* user :: A typeless pointer, which is passed from the caller of the */
488+ /* decomposition function. */
489+ /* */
490+ /* <Return> */
491+ /* Error code. 0~means success. */
492+ /* */
493+ typedef int
494+ (*FT_Outline_MoveToFunc)( const FT_Vector* to,
495+ void* user );
496+
497+#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
498+
499+
500+ /*************************************************************************/
501+ /* */
502+ /* <FuncType> */
503+ /* FT_Outline_LineToFunc */
504+ /* */
505+ /* <Description> */
506+ /* A function pointer type used to describe the signature of a `line */
507+ /* to' function during outline walking/decomposition. */
508+ /* */
509+ /* A `line to' is emitted to indicate a segment in the outline. */
510+ /* */
511+ /* <Input> */
512+ /* to :: A pointer to the target point of the `line to'. */
513+ /* */
514+ /* user :: A typeless pointer, which is passed from the caller of the */
515+ /* decomposition function. */
516+ /* */
517+ /* <Return> */
518+ /* Error code. 0~means success. */
519+ /* */
520+ typedef int
521+ (*FT_Outline_LineToFunc)( const FT_Vector* to,
522+ void* user );
523+
524+#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
525+
526+
527+ /*************************************************************************/
528+ /* */
529+ /* <FuncType> */
530+ /* FT_Outline_ConicToFunc */
531+ /* */
532+ /* <Description> */
533+ /* A function pointer type used to describe the signature of a `conic */
534+ /* to' function during outline walking or decomposition. */
535+ /* */
536+ /* A `conic to' is emitted to indicate a second-order Bezier arc in */
537+ /* the outline. */
538+ /* */
539+ /* <Input> */
540+ /* control :: An intermediate control point between the last position */
541+ /* and the new target in `to'. */
542+ /* */
543+ /* to :: A pointer to the target end point of the conic arc. */
544+ /* */
545+ /* user :: A typeless pointer, which is passed from the caller of */
546+ /* the decomposition function. */
547+ /* */
548+ /* <Return> */
549+ /* Error code. 0~means success. */
550+ /* */
551+ typedef int
552+ (*FT_Outline_ConicToFunc)( const FT_Vector* control,
553+ const FT_Vector* to,
554+ void* user );
555+
556+#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
557+
558+
559+ /*************************************************************************/
560+ /* */
561+ /* <FuncType> */
562+ /* FT_Outline_CubicToFunc */
563+ /* */
564+ /* <Description> */
565+ /* A function pointer type used to describe the signature of a `cubic */
566+ /* to' function during outline walking or decomposition. */
567+ /* */
568+ /* A `cubic to' is emitted to indicate a third-order Bezier arc. */
569+ /* */
570+ /* <Input> */
571+ /* control1 :: A pointer to the first Bezier control point. */
572+ /* */
573+ /* control2 :: A pointer to the second Bezier control point. */
574+ /* */
575+ /* to :: A pointer to the target end point. */
576+ /* */
577+ /* user :: A typeless pointer, which is passed from the caller of */
578+ /* the decomposition function. */
579+ /* */
580+ /* <Return> */
581+ /* Error code. 0~means success. */
582+ /* */
583+ typedef int
584+ (*FT_Outline_CubicToFunc)( const FT_Vector* control1,
585+ const FT_Vector* control2,
586+ const FT_Vector* to,
587+ void* user );
588+
589+#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
590+
591+
592+ /*************************************************************************/
593+ /* */
594+ /* <Struct> */
595+ /* FT_Outline_Funcs */
596+ /* */
597+ /* <Description> */
598+ /* A structure to hold various function pointers used during outline */
599+ /* decomposition in order to emit segments, conic, and cubic Beziers. */
600+ /* */
601+ /* <Fields> */
602+ /* move_to :: The `move to' emitter. */
603+ /* */
604+ /* line_to :: The segment emitter. */
605+ /* */
606+ /* conic_to :: The second-order Bezier arc emitter. */
607+ /* */
608+ /* cubic_to :: The third-order Bezier arc emitter. */
609+ /* */
610+ /* shift :: The shift that is applied to coordinates before they */
611+ /* are sent to the emitter. */
612+ /* */
613+ /* delta :: The delta that is applied to coordinates before they */
614+ /* are sent to the emitter, but after the shift. */
615+ /* */
616+ /* <Note> */
617+ /* The point coordinates sent to the emitters are the transformed */
618+ /* version of the original coordinates (this is important for high */
619+ /* accuracy during scan-conversion). The transformation is simple: */
620+ /* */
621+ /* { */
622+ /* x' = (x << shift) - delta */
623+ /* y' = (y << shift) - delta */
624+ /* } */
625+ /* */
626+ /* Set the values of `shift' and `delta' to~0 to get the original */
627+ /* point coordinates. */
628+ /* */
629+ typedef struct FT_Outline_Funcs_
630+ {
631+ FT_Outline_MoveToFunc move_to;
632+ FT_Outline_LineToFunc line_to;
633+ FT_Outline_ConicToFunc conic_to;
634+ FT_Outline_CubicToFunc cubic_to;
635+
636+ int shift;
637+ FT_Pos delta;
638+
639+ } FT_Outline_Funcs;
640+
641+
642+ /*************************************************************************/
643+ /* */
644+ /* <Section> */
645+ /* basic_types */
646+ /* */
647+ /*************************************************************************/
648+
649+
650+ /*************************************************************************/
651+ /* */
652+ /* <Macro> */
653+ /* FT_IMAGE_TAG */
654+ /* */
655+ /* <Description> */
656+ /* This macro converts four-letter tags to an unsigned long type. */
657+ /* */
658+ /* <Note> */
659+ /* Since many 16-bit compilers don't like 32-bit enumerations, you */
660+ /* should redefine this macro in case of problems to something like */
661+ /* this: */
662+ /* */
663+ /* { */
664+ /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
665+ /* } */
666+ /* */
667+ /* to get a simple enumeration without assigning special numbers. */
668+ /* */
669+#ifndef FT_IMAGE_TAG
670+#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
671+ value = ( ( (unsigned long)_x1 << 24 ) | \
672+ ( (unsigned long)_x2 << 16 ) | \
673+ ( (unsigned long)_x3 << 8 ) | \
674+ (unsigned long)_x4 )
675+#endif /* FT_IMAGE_TAG */
676+
677+
678+ /*************************************************************************/
679+ /* */
680+ /* <Enum> */
681+ /* FT_Glyph_Format */
682+ /* */
683+ /* <Description> */
684+ /* An enumeration type used to describe the format of a given glyph */
685+ /* image. Note that this version of FreeType only supports two image */
686+ /* formats, even though future font drivers will be able to register */
687+ /* their own format. */
688+ /* */
689+ /* <Values> */
690+ /* FT_GLYPH_FORMAT_NONE :: */
691+ /* The value~0 is reserved. */
692+ /* */
693+ /* FT_GLYPH_FORMAT_COMPOSITE :: */
694+ /* The glyph image is a composite of several other images. This */
695+ /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */
696+ /* report compound glyphs (like accented characters). */
697+ /* */
698+ /* FT_GLYPH_FORMAT_BITMAP :: */
699+ /* The glyph image is a bitmap, and can be described as an */
700+ /* @FT_Bitmap. You generally need to access the `bitmap' field of */
701+ /* the @FT_GlyphSlotRec structure to read it. */
702+ /* */
703+ /* FT_GLYPH_FORMAT_OUTLINE :: */
704+ /* The glyph image is a vectorial outline made of line segments */
705+ /* and Bezier arcs; it can be described as an @FT_Outline; you */
706+ /* generally want to access the `outline' field of the */
707+ /* @FT_GlyphSlotRec structure to read it. */
708+ /* */
709+ /* FT_GLYPH_FORMAT_PLOTTER :: */
710+ /* The glyph image is a vectorial path with no inside and outside */
711+ /* contours. Some Type~1 fonts, like those in the Hershey family, */
712+ /* contain glyphs in this format. These are described as */
713+ /* @FT_Outline, but FreeType isn't currently capable of rendering */
714+ /* them correctly. */
715+ /* */
716+ typedef enum FT_Glyph_Format_
717+ {
718+ FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
719+
720+ FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
721+ FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
722+ FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
723+ FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
724+
725+ } FT_Glyph_Format;
726+
727+
728+ /* these constants are deprecated; use the corresponding */
729+ /* `FT_Glyph_Format' values instead. */
730+#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
731+#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
732+#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
733+#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
734+#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
735+
736+
737+ /*************************************************************************/
738+ /*************************************************************************/
739+ /*************************************************************************/
740+ /***** *****/
741+ /***** R A S T E R D E F I N I T I O N S *****/
742+ /***** *****/
743+ /*************************************************************************/
744+ /*************************************************************************/
745+ /*************************************************************************/
746+
747+
748+ /*************************************************************************/
749+ /* */
750+ /* A raster is a scan converter, in charge of rendering an outline into */
751+ /* a bitmap. This section contains the public API for rasters. */
752+ /* */
753+ /* Note that in FreeType 2, all rasters are now encapsulated within */
754+ /* specific modules called `renderers'. See `ftrender.h' for more */
755+ /* details on renderers. */
756+ /* */
757+ /*************************************************************************/
758+
759+
760+ /*************************************************************************/
761+ /* */
762+ /* <Section> */
763+ /* raster */
764+ /* */
765+ /* <Title> */
766+ /* Scanline Converter */
767+ /* */
768+ /* <Abstract> */
769+ /* How vectorial outlines are converted into bitmaps and pixmaps. */
770+ /* */
771+ /* <Description> */
772+ /* This section contains technical definitions. */
773+ /* */
774+ /* <Order> */
775+ /* FT_Raster */
776+ /* FT_Span */
777+ /* FT_SpanFunc */
778+ /* */
779+ /* FT_Raster_Params */
780+ /* FT_RASTER_FLAG_XXX */
781+ /* */
782+ /* FT_Raster_NewFunc */
783+ /* FT_Raster_DoneFunc */
784+ /* FT_Raster_ResetFunc */
785+ /* FT_Raster_SetModeFunc */
786+ /* FT_Raster_RenderFunc */
787+ /* FT_Raster_Funcs */
788+ /* */
789+ /*************************************************************************/
790+
791+
792+ /*************************************************************************/
793+ /* */
794+ /* <Type> */
795+ /* FT_Raster */
796+ /* */
797+ /* <Description> */
798+ /* An opaque handle (pointer) to a raster object. Each object can be */
799+ /* used independently to convert an outline into a bitmap or pixmap. */
800+ /* */
801+ typedef struct FT_RasterRec_* FT_Raster;
802+
803+
804+ /*************************************************************************/
805+ /* */
806+ /* <Struct> */
807+ /* FT_Span */
808+ /* */
809+ /* <Description> */
810+ /* A structure used to model a single span of gray pixels when */
811+ /* rendering an anti-aliased bitmap. */
812+ /* */
813+ /* <Fields> */
814+ /* x :: The span's horizontal start position. */
815+ /* */
816+ /* len :: The span's length in pixels. */
817+ /* */
818+ /* coverage :: The span color/coverage, ranging from 0 (background) */
819+ /* to 255 (foreground). */
820+ /* */
821+ /* <Note> */
822+ /* This structure is used by the span drawing callback type named */
823+ /* @FT_SpanFunc that takes the y~coordinate of the span as a */
824+ /* parameter. */
825+ /* */
826+ /* The coverage value is always between 0 and 255. If you want less */
827+ /* gray values, the callback function has to reduce them. */
828+ /* */
829+ typedef struct FT_Span_
830+ {
831+ short x;
832+ unsigned short len;
833+ unsigned char coverage;
834+
835+ } FT_Span;
836+
837+
838+ /*************************************************************************/
839+ /* */
840+ /* <FuncType> */
841+ /* FT_SpanFunc */
842+ /* */
843+ /* <Description> */
844+ /* A function used as a call-back by the anti-aliased renderer in */
845+ /* order to let client applications draw themselves the gray pixel */
846+ /* spans on each scan line. */
847+ /* */
848+ /* <Input> */
849+ /* y :: The scanline's y~coordinate. */
850+ /* */
851+ /* count :: The number of spans to draw on this scanline. */
852+ /* */
853+ /* spans :: A table of `count' spans to draw on the scanline. */
854+ /* */
855+ /* user :: User-supplied data that is passed to the callback. */
856+ /* */
857+ /* <Note> */
858+ /* This callback allows client applications to directly render the */
859+ /* gray spans of the anti-aliased bitmap to any kind of surfaces. */
860+ /* */
861+ /* This can be used to write anti-aliased outlines directly to a */
862+ /* given background bitmap, and even perform translucency. */
863+ /* */
864+ typedef void
865+ (*FT_SpanFunc)( int y,
866+ int count,
867+ const FT_Span* spans,
868+ void* user );
869+
870+#define FT_Raster_Span_Func FT_SpanFunc
871+
872+
873+ /*************************************************************************/
874+ /* */
875+ /* <FuncType> */
876+ /* FT_Raster_BitTest_Func */
877+ /* */
878+ /* <Description> */
879+ /* Deprecated, unimplemented. */
880+ /* */
881+ typedef int
882+ (*FT_Raster_BitTest_Func)( int y,
883+ int x,
884+ void* user );
885+
886+
887+ /*************************************************************************/
888+ /* */
889+ /* <FuncType> */
890+ /* FT_Raster_BitSet_Func */
891+ /* */
892+ /* <Description> */
893+ /* Deprecated, unimplemented. */
894+ /* */
895+ typedef void
896+ (*FT_Raster_BitSet_Func)( int y,
897+ int x,
898+ void* user );
899+
900+
901+ /*************************************************************************/
902+ /* */
903+ /* <Enum> */
904+ /* FT_RASTER_FLAG_XXX */
905+ /* */
906+ /* <Description> */
907+ /* A list of bit flag constants as used in the `flags' field of a */
908+ /* @FT_Raster_Params structure. */
909+ /* */
910+ /* <Values> */
911+ /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
912+ /* */
913+ /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
914+ /* anti-aliased glyph image should be */
915+ /* generated. Otherwise, it will be */
916+ /* monochrome (1-bit). */
917+ /* */
918+ /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
919+ /* rendering. In this mode, client */
920+ /* applications must provide their own span */
921+ /* callback. This lets them directly */
922+ /* draw or compose over an existing bitmap. */
923+ /* If this bit is not set, the target */
924+ /* pixmap's buffer _must_ be zeroed before */
925+ /* rendering. */
926+ /* */
927+ /* Direct rendering is only possible with */
928+ /* anti-aliased glyphs. */
929+ /* */
930+ /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
931+ /* rendering mode. If set, the output will */
932+ /* be clipped to a box specified in the */
933+ /* `clip_box' field of the */
934+ /* @FT_Raster_Params structure. */
935+ /* */
936+ /* Note that by default, the glyph bitmap */
937+ /* is clipped to the target pixmap, except */
938+ /* in direct rendering mode where all spans */
939+ /* are generated if no clipping box is set. */
940+ /* */
941+#define FT_RASTER_FLAG_DEFAULT 0x0
942+#define FT_RASTER_FLAG_AA 0x1
943+#define FT_RASTER_FLAG_DIRECT 0x2
944+#define FT_RASTER_FLAG_CLIP 0x4
945+
946+ /* these constants are deprecated; use the corresponding */
947+ /* `FT_RASTER_FLAG_XXX' values instead */
948+#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
949+#define ft_raster_flag_aa FT_RASTER_FLAG_AA
950+#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
951+#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
952+
953+
954+ /*************************************************************************/
955+ /* */
956+ /* <Struct> */
957+ /* FT_Raster_Params */
958+ /* */
959+ /* <Description> */
960+ /* A structure to hold the arguments used by a raster's render */
961+ /* function. */
962+ /* */
963+ /* <Fields> */
964+ /* target :: The target bitmap. */
965+ /* */
966+ /* source :: A pointer to the source glyph image (e.g., an */
967+ /* @FT_Outline). */
968+ /* */
969+ /* flags :: The rendering flags. */
970+ /* */
971+ /* gray_spans :: The gray span drawing callback. */
972+ /* */
973+ /* black_spans :: Unused. */
974+ /* */
975+ /* bit_test :: Unused. */
976+ /* */
977+ /* bit_set :: Unused. */
978+ /* */
979+ /* user :: User-supplied data that is passed to each drawing */
980+ /* callback. */
981+ /* */
982+ /* clip_box :: An optional clipping box. It is only used in */
983+ /* direct rendering mode. Note that coordinates here */
984+ /* should be expressed in _integer_ pixels (and not in */
985+ /* 26.6 fixed-point units). */
986+ /* */
987+ /* <Note> */
988+ /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */
989+ /* bit flag is set in the `flags' field, otherwise a monochrome */
990+ /* bitmap is generated. */
991+ /* */
992+ /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
993+ /* raster will call the `gray_spans' callback to draw gray pixel */
994+ /* spans. This allows direct composition over a pre-existing bitmap */
995+ /* through user-provided callbacks to perform the span drawing and */
996+ /* composition. Not supported by the monochrome rasterizer. */
997+ /* */
998+ typedef struct FT_Raster_Params_
999+ {
1000+ const FT_Bitmap* target;
1001+ const void* source;
1002+ int flags;
1003+ FT_SpanFunc gray_spans;
1004+ FT_SpanFunc black_spans; /* unused */
1005+ FT_Raster_BitTest_Func bit_test; /* unused */
1006+ FT_Raster_BitSet_Func bit_set; /* unused */
1007+ void* user;
1008+ FT_BBox clip_box;
1009+
1010+ } FT_Raster_Params;
1011+
1012+
1013+ /*************************************************************************/
1014+ /* */
1015+ /* <FuncType> */
1016+ /* FT_Raster_NewFunc */
1017+ /* */
1018+ /* <Description> */
1019+ /* A function used to create a new raster object. */
1020+ /* */
1021+ /* <Input> */
1022+ /* memory :: A handle to the memory allocator. */
1023+ /* */
1024+ /* <Output> */
1025+ /* raster :: A handle to the new raster object. */
1026+ /* */
1027+ /* <Return> */
1028+ /* Error code. 0~means success. */
1029+ /* */
1030+ /* <Note> */
1031+ /* The `memory' parameter is a typeless pointer in order to avoid */
1032+ /* un-wanted dependencies on the rest of the FreeType code. In */
1033+ /* practice, it is an @FT_Memory object, i.e., a handle to the */
1034+ /* standard FreeType memory allocator. However, this field can be */
1035+ /* completely ignored by a given raster implementation. */
1036+ /* */
1037+ typedef int
1038+ (*FT_Raster_NewFunc)( void* memory,
1039+ FT_Raster* raster );
1040+
1041+#define FT_Raster_New_Func FT_Raster_NewFunc
1042+
1043+
1044+ /*************************************************************************/
1045+ /* */
1046+ /* <FuncType> */
1047+ /* FT_Raster_DoneFunc */
1048+ /* */
1049+ /* <Description> */
1050+ /* A function used to destroy a given raster object. */
1051+ /* */
1052+ /* <Input> */
1053+ /* raster :: A handle to the raster object. */
1054+ /* */
1055+ typedef void
1056+ (*FT_Raster_DoneFunc)( FT_Raster raster );
1057+
1058+#define FT_Raster_Done_Func FT_Raster_DoneFunc
1059+
1060+
1061+ /*************************************************************************/
1062+ /* */
1063+ /* <FuncType> */
1064+ /* FT_Raster_ResetFunc */
1065+ /* */
1066+ /* <Description> */
1067+ /* FreeType used to provide an area of memory called the `render */
1068+ /* pool' available to all registered rasterizers. This was not */
1069+ /* thread safe, however, and now FreeType never allocates this pool. */
1070+ /* */
1071+ /* This function is called after a new raster object is created. */
1072+ /* */
1073+ /* <Input> */
1074+ /* raster :: A handle to the new raster object. */
1075+ /* */
1076+ /* pool_base :: Previously, the address in memory of the render pool. */
1077+ /* Set this to NULL. */
1078+ /* */
1079+ /* pool_size :: Previously, the size in bytes of the render pool. */
1080+ /* Set this to 0. */
1081+ /* */
1082+ /* <Note> */
1083+ /* Rasterizers should rely on dynamic or stack allocation if they */
1084+ /* want to (a handle to the memory allocator is passed to the */
1085+ /* rasterizer constructor). */
1086+ /* */
1087+ typedef void
1088+ (*FT_Raster_ResetFunc)( FT_Raster raster,
1089+ unsigned char* pool_base,
1090+ unsigned long pool_size );
1091+
1092+#define FT_Raster_Reset_Func FT_Raster_ResetFunc
1093+
1094+
1095+ /*************************************************************************/
1096+ /* */
1097+ /* <FuncType> */
1098+ /* FT_Raster_SetModeFunc */
1099+ /* */
1100+ /* <Description> */
1101+ /* This function is a generic facility to change modes or attributes */
1102+ /* in a given raster. This can be used for debugging purposes, or */
1103+ /* simply to allow implementation-specific `features' in a given */
1104+ /* raster module. */
1105+ /* */
1106+ /* <Input> */
1107+ /* raster :: A handle to the new raster object. */
1108+ /* */
1109+ /* mode :: A 4-byte tag used to name the mode or property. */
1110+ /* */
1111+ /* args :: A pointer to the new mode/property to use. */
1112+ /* */
1113+ typedef int
1114+ (*FT_Raster_SetModeFunc)( FT_Raster raster,
1115+ unsigned long mode,
1116+ void* args );
1117+
1118+#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
1119+
1120+
1121+ /*************************************************************************/
1122+ /* */
1123+ /* <FuncType> */
1124+ /* FT_Raster_RenderFunc */
1125+ /* */
1126+ /* <Description> */
1127+ /* Invoke a given raster to scan-convert a given glyph image into a */
1128+ /* target bitmap. */
1129+ /* */
1130+ /* <Input> */
1131+ /* raster :: A handle to the raster object. */
1132+ /* */
1133+ /* params :: A pointer to an @FT_Raster_Params structure used to */
1134+ /* store the rendering parameters. */
1135+ /* */
1136+ /* <Return> */
1137+ /* Error code. 0~means success. */
1138+ /* */
1139+ /* <Note> */
1140+ /* The exact format of the source image depends on the raster's glyph */
1141+ /* format defined in its @FT_Raster_Funcs structure. It can be an */
1142+ /* @FT_Outline or anything else in order to support a large array of */
1143+ /* glyph formats. */
1144+ /* */
1145+ /* Note also that the render function can fail and return a */
1146+ /* `FT_Err_Unimplemented_Feature' error code if the raster used does */
1147+ /* not support direct composition. */
1148+ /* */
1149+ /* XXX: For now, the standard raster doesn't support direct */
1150+ /* composition but this should change for the final release (see */
1151+ /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */
1152+ /* for examples of distinct implementations that support direct */
1153+ /* composition). */
1154+ /* */
1155+ typedef int
1156+ (*FT_Raster_RenderFunc)( FT_Raster raster,
1157+ const FT_Raster_Params* params );
1158+
1159+#define FT_Raster_Render_Func FT_Raster_RenderFunc
1160+
1161+
1162+ /*************************************************************************/
1163+ /* */
1164+ /* <Struct> */
1165+ /* FT_Raster_Funcs */
1166+ /* */
1167+ /* <Description> */
1168+ /* A structure used to describe a given raster class to the library. */
1169+ /* */
1170+ /* <Fields> */
1171+ /* glyph_format :: The supported glyph format for this raster. */
1172+ /* */
1173+ /* raster_new :: The raster constructor. */
1174+ /* */
1175+ /* raster_reset :: Used to reset the render pool within the raster. */
1176+ /* */
1177+ /* raster_render :: A function to render a glyph into a given bitmap. */
1178+ /* */
1179+ /* raster_done :: The raster destructor. */
1180+ /* */
1181+ typedef struct FT_Raster_Funcs_
1182+ {
1183+ FT_Glyph_Format glyph_format;
1184+
1185+ FT_Raster_NewFunc raster_new;
1186+ FT_Raster_ResetFunc raster_reset;
1187+ FT_Raster_SetModeFunc raster_set_mode;
1188+ FT_Raster_RenderFunc raster_render;
1189+ FT_Raster_DoneFunc raster_done;
1190+
1191+ } FT_Raster_Funcs;
1192+
1193+ /* */
1194+
1195+
1196+FT_END_HEADER
1197+
1198+#endif /* FTIMAGE_H_ */
1199+
1200+
1201+/* END */
1202+
1203+
1204+/* Local Variables: */
1205+/* coding: utf-8 */
1206+/* End: */
1@@ -0,0 +1,343 @@
2+/***************************************************************************/
3+/* */
4+/* ftincrem.h */
5+/* */
6+/* FreeType incremental loading (specification). */
7+/* */
8+/* Copyright 2002-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTINCREM_H_
21+#define FTINCREM_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+#include FT_PARAMETER_TAGS_H
26+
27+#ifdef FREETYPE_H
28+#error "freetype.h of FreeType 1 has been loaded!"
29+#error "Please fix the directory search order for header files"
30+#error "so that freetype.h of FreeType 2 is found first."
31+#endif
32+
33+
34+FT_BEGIN_HEADER
35+
36+ /***************************************************************************
37+ *
38+ * @section:
39+ * incremental
40+ *
41+ * @title:
42+ * Incremental Loading
43+ *
44+ * @abstract:
45+ * Custom Glyph Loading.
46+ *
47+ * @description:
48+ * This section contains various functions used to perform so-called
49+ * `incremental' glyph loading. This is a mode where all glyphs loaded
50+ * from a given @FT_Face are provided by the client application.
51+ *
52+ * Apart from that, all other tables are loaded normally from the font
53+ * file. This mode is useful when FreeType is used within another
54+ * engine, e.g., a PostScript Imaging Processor.
55+ *
56+ * To enable this mode, you must use @FT_Open_Face, passing an
57+ * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an
58+ * @FT_Incremental_Interface value. See the comments for
59+ * @FT_Incremental_InterfaceRec for an example.
60+ *
61+ */
62+
63+
64+ /***************************************************************************
65+ *
66+ * @type:
67+ * FT_Incremental
68+ *
69+ * @description:
70+ * An opaque type describing a user-provided object used to implement
71+ * `incremental' glyph loading within FreeType. This is used to support
72+ * embedded fonts in certain environments (e.g., PostScript interpreters),
73+ * where the glyph data isn't in the font file, or must be overridden by
74+ * different values.
75+ *
76+ * @note:
77+ * It is up to client applications to create and implement @FT_Incremental
78+ * objects, as long as they provide implementations for the methods
79+ * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc
80+ * and @FT_Incremental_GetGlyphMetricsFunc.
81+ *
82+ * See the description of @FT_Incremental_InterfaceRec to understand how
83+ * to use incremental objects with FreeType.
84+ *
85+ */
86+ typedef struct FT_IncrementalRec_* FT_Incremental;
87+
88+
89+ /***************************************************************************
90+ *
91+ * @struct:
92+ * FT_Incremental_MetricsRec
93+ *
94+ * @description:
95+ * A small structure used to contain the basic glyph metrics returned
96+ * by the @FT_Incremental_GetGlyphMetricsFunc method.
97+ *
98+ * @fields:
99+ * bearing_x ::
100+ * Left bearing, in font units.
101+ *
102+ * bearing_y ::
103+ * Top bearing, in font units.
104+ *
105+ * advance ::
106+ * Horizontal component of glyph advance, in font units.
107+ *
108+ * advance_v ::
109+ * Vertical component of glyph advance, in font units.
110+ *
111+ * @note:
112+ * These correspond to horizontal or vertical metrics depending on the
113+ * value of the `vertical' argument to the function
114+ * @FT_Incremental_GetGlyphMetricsFunc.
115+ *
116+ */
117+ typedef struct FT_Incremental_MetricsRec_
118+ {
119+ FT_Long bearing_x;
120+ FT_Long bearing_y;
121+ FT_Long advance;
122+ FT_Long advance_v; /* since 2.3.12 */
123+
124+ } FT_Incremental_MetricsRec;
125+
126+
127+ /***************************************************************************
128+ *
129+ * @struct:
130+ * FT_Incremental_Metrics
131+ *
132+ * @description:
133+ * A handle to an @FT_Incremental_MetricsRec structure.
134+ *
135+ */
136+ typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics;
137+
138+
139+ /***************************************************************************
140+ *
141+ * @type:
142+ * FT_Incremental_GetGlyphDataFunc
143+ *
144+ * @description:
145+ * A function called by FreeType to access a given glyph's data bytes
146+ * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
147+ * enabled.
148+ *
149+ * Note that the format of the glyph's data bytes depends on the font
150+ * file format. For TrueType, it must correspond to the raw bytes within
151+ * the `glyf' table. For PostScript formats, it must correspond to the
152+ * *unencrypted* charstring bytes, without any `lenIV' header. It is
153+ * undefined for any other format.
154+ *
155+ * @input:
156+ * incremental ::
157+ * Handle to an opaque @FT_Incremental handle provided by the client
158+ * application.
159+ *
160+ * glyph_index ::
161+ * Index of relevant glyph.
162+ *
163+ * @output:
164+ * adata ::
165+ * A structure describing the returned glyph data bytes (which will be
166+ * accessed as a read-only byte block).
167+ *
168+ * @return:
169+ * FreeType error code. 0~means success.
170+ *
171+ * @note:
172+ * If this function returns successfully the method
173+ * @FT_Incremental_FreeGlyphDataFunc will be called later to release
174+ * the data bytes.
175+ *
176+ * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
177+ * compound glyphs.
178+ *
179+ */
180+ typedef FT_Error
181+ (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
182+ FT_UInt glyph_index,
183+ FT_Data* adata );
184+
185+
186+ /***************************************************************************
187+ *
188+ * @type:
189+ * FT_Incremental_FreeGlyphDataFunc
190+ *
191+ * @description:
192+ * A function used to release the glyph data bytes returned by a
193+ * successful call to @FT_Incremental_GetGlyphDataFunc.
194+ *
195+ * @input:
196+ * incremental ::
197+ * A handle to an opaque @FT_Incremental handle provided by the client
198+ * application.
199+ *
200+ * data ::
201+ * A structure describing the glyph data bytes (which will be accessed
202+ * as a read-only byte block).
203+ *
204+ */
205+ typedef void
206+ (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
207+ FT_Data* data );
208+
209+
210+ /***************************************************************************
211+ *
212+ * @type:
213+ * FT_Incremental_GetGlyphMetricsFunc
214+ *
215+ * @description:
216+ * A function used to retrieve the basic metrics of a given glyph index
217+ * before accessing its data. This is necessary because, in certain
218+ * formats like TrueType, the metrics are stored in a different place from
219+ * the glyph images proper.
220+ *
221+ * @input:
222+ * incremental ::
223+ * A handle to an opaque @FT_Incremental handle provided by the client
224+ * application.
225+ *
226+ * glyph_index ::
227+ * Index of relevant glyph.
228+ *
229+ * vertical ::
230+ * If true, return vertical metrics.
231+ *
232+ * ametrics ::
233+ * This parameter is used for both input and output.
234+ * The original glyph metrics, if any, in font units. If metrics are
235+ * not available all the values must be set to zero.
236+ *
237+ * @output:
238+ * ametrics ::
239+ * The replacement glyph metrics in font units.
240+ *
241+ */
242+ typedef FT_Error
243+ (*FT_Incremental_GetGlyphMetricsFunc)
244+ ( FT_Incremental incremental,
245+ FT_UInt glyph_index,
246+ FT_Bool vertical,
247+ FT_Incremental_MetricsRec *ametrics );
248+
249+
250+ /**************************************************************************
251+ *
252+ * @struct:
253+ * FT_Incremental_FuncsRec
254+ *
255+ * @description:
256+ * A table of functions for accessing fonts that load data
257+ * incrementally. Used in @FT_Incremental_InterfaceRec.
258+ *
259+ * @fields:
260+ * get_glyph_data ::
261+ * The function to get glyph data. Must not be null.
262+ *
263+ * free_glyph_data ::
264+ * The function to release glyph data. Must not be null.
265+ *
266+ * get_glyph_metrics ::
267+ * The function to get glyph metrics. May be null if the font does
268+ * not provide overriding glyph metrics.
269+ *
270+ */
271+ typedef struct FT_Incremental_FuncsRec_
272+ {
273+ FT_Incremental_GetGlyphDataFunc get_glyph_data;
274+ FT_Incremental_FreeGlyphDataFunc free_glyph_data;
275+ FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
276+
277+ } FT_Incremental_FuncsRec;
278+
279+
280+ /***************************************************************************
281+ *
282+ * @struct:
283+ * FT_Incremental_InterfaceRec
284+ *
285+ * @description:
286+ * A structure to be used with @FT_Open_Face to indicate that the user
287+ * wants to support incremental glyph loading. You should use it with
288+ * @FT_PARAM_TAG_INCREMENTAL as in the following example:
289+ *
290+ * {
291+ * FT_Incremental_InterfaceRec inc_int;
292+ * FT_Parameter parameter;
293+ * FT_Open_Args open_args;
294+ *
295+ *
296+ * // set up incremental descriptor
297+ * inc_int.funcs = my_funcs;
298+ * inc_int.object = my_object;
299+ *
300+ * // set up optional parameter
301+ * parameter.tag = FT_PARAM_TAG_INCREMENTAL;
302+ * parameter.data = &inc_int;
303+ *
304+ * // set up FT_Open_Args structure
305+ * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
306+ * open_args.pathname = my_font_pathname;
307+ * open_args.num_params = 1;
308+ * open_args.params = ¶meter; // we use one optional argument
309+ *
310+ * // open the font
311+ * error = FT_Open_Face( library, &open_args, index, &face );
312+ * ...
313+ * }
314+ *
315+ */
316+ typedef struct FT_Incremental_InterfaceRec_
317+ {
318+ const FT_Incremental_FuncsRec* funcs;
319+ FT_Incremental object;
320+
321+ } FT_Incremental_InterfaceRec;
322+
323+
324+ /***************************************************************************
325+ *
326+ * @type:
327+ * FT_Incremental_Interface
328+ *
329+ * @description:
330+ * A pointer to an @FT_Incremental_InterfaceRec structure.
331+ *
332+ */
333+ typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface;
334+
335+
336+ /* */
337+
338+
339+FT_END_HEADER
340+
341+#endif /* FTINCREM_H_ */
342+
343+
344+/* END */
1@@ -0,0 +1,309 @@
2+/***************************************************************************/
3+/* */
4+/* ftlcdfil.h */
5+/* */
6+/* FreeType API for color filtering of subpixel bitmap glyphs */
7+/* (specification). */
8+/* */
9+/* Copyright 2006-2018 by */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+
21+#ifndef FTLCDFIL_H_
22+#define FTLCDFIL_H_
23+
24+#include <ft2build.h>
25+#include FT_FREETYPE_H
26+#include FT_PARAMETER_TAGS_H
27+
28+#ifdef FREETYPE_H
29+#error "freetype.h of FreeType 1 has been loaded!"
30+#error "Please fix the directory search order for header files"
31+#error "so that freetype.h of FreeType 2 is found first."
32+#endif
33+
34+
35+FT_BEGIN_HEADER
36+
37+ /***************************************************************************
38+ *
39+ * @section:
40+ * lcd_filtering
41+ *
42+ * @title:
43+ * LCD Filtering
44+ *
45+ * @abstract:
46+ * Reduce color fringes of subpixel-rendered bitmaps.
47+ *
48+ * @description:
49+ * Should you #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your
50+ * `ftoption.h', which enables patented ClearType-style rendering,
51+ * the LCD-optimized glyph bitmaps should be filtered to reduce color
52+ * fringes inherent to this technology. The default FreeType LCD
53+ * rendering uses different technology, and API described below,
54+ * although available, does nothing.
55+ *
56+ * ClearType-style LCD rendering exploits the color-striped structure of
57+ * LCD pixels, increasing the available resolution in the direction of
58+ * the stripe (usually horizontal RGB) by a factor of~3. Since these
59+ * subpixels are color pixels, using them unfiltered creates severe
60+ * color fringes. Use the @FT_Library_SetLcdFilter API to specify a
61+ * low-pass filter, which is then applied to subpixel-rendered bitmaps
62+ * generated through @FT_Render_Glyph. The filter sacrifices some of
63+ * the higher resolution to reduce color fringes, making the glyph image
64+ * slightly blurrier. Positional improvements will remain.
65+ *
66+ * A filter should have two properties:
67+ *
68+ * 1) It should be normalized, meaning the sum of the 5~components
69+ * should be 256 (0x100). It is possible to go above or under this
70+ * target sum, however: going under means tossing out contrast, going
71+ * over means invoking clamping and thereby non-linearities that
72+ * increase contrast somewhat at the expense of greater distortion
73+ * and color-fringing. Contrast is better enhanced through stem
74+ * darkening.
75+ *
76+ * 2) It should be color-balanced, meaning a filter `{~a, b, c, b, a~}'
77+ * where a~+ b~=~c. It distributes the computed coverage for one
78+ * subpixel to all subpixels equally, sacrificing some won resolution
79+ * but drastically reducing color-fringing. Positioning improvements
80+ * remain! Note that color-fringing can only really be minimized
81+ * when using a color-balanced filter and alpha-blending the glyph
82+ * onto a surface in linear space; see @FT_Render_Glyph.
83+ *
84+ * Regarding the form, a filter can be a `boxy' filter or a `beveled'
85+ * filter. Boxy filters are sharper but are less forgiving of non-ideal
86+ * gamma curves of a screen (viewing angles!), beveled filters are
87+ * fuzzier but more tolerant.
88+ *
89+ * Examples:
90+ *
91+ * - [0x10 0x40 0x70 0x40 0x10] is beveled and neither balanced nor
92+ * normalized.
93+ *
94+ * - [0x1A 0x33 0x4D 0x33 0x1A] is beveled and balanced but not
95+ * normalized.
96+ *
97+ * - [0x19 0x33 0x66 0x4c 0x19] is beveled and normalized but not
98+ * balanced.
99+ *
100+ * - [0x00 0x4c 0x66 0x4c 0x00] is boxily beveled and normalized but not
101+ * balanced.
102+ *
103+ * - [0x00 0x55 0x56 0x55 0x00] is boxy, normalized, and almost
104+ * balanced.
105+ *
106+ * - [0x08 0x4D 0x56 0x4D 0x08] is beveled, normalized and, almost
107+ * balanced.
108+ *
109+ * The filter affects glyph bitmaps rendered through @FT_Render_Glyph,
110+ * @FT_Load_Glyph, and @FT_Load_Char. It does _not_ affect the output
111+ * of @FT_Outline_Render and @FT_Outline_Get_Bitmap.
112+ *
113+ * If this feature is activated, the dimensions of LCD glyph bitmaps are
114+ * either wider or taller than the dimensions of the corresponding
115+ * outline with regard to the pixel grid. For example, for
116+ * @FT_RENDER_MODE_LCD, the filter adds 3~subpixels to the left, and
117+ * 3~subpixels to the right. The bitmap offset values are adjusted
118+ * accordingly, so clients shouldn't need to modify their layout and
119+ * glyph positioning code when enabling the filter.
120+ *
121+ * It is important to understand that linear alpha blending and gamma
122+ * correction is critical for correctly rendering glyphs onto surfaces
123+ * without artifacts and even more critical when subpixel rendering is
124+ * involved.
125+ *
126+ * Each of the 3~alpha values (subpixels) is independently used to blend
127+ * one color channel. That is, red alpha blends the red channel of the
128+ * text color with the red channel of the background pixel. The
129+ * distribution of density values by the color-balanced filter assumes
130+ * alpha blending is done in linear space; only then color artifacts
131+ * cancel out.
132+ */
133+
134+
135+ /****************************************************************************
136+ *
137+ * @enum:
138+ * FT_LcdFilter
139+ *
140+ * @description:
141+ * A list of values to identify various types of LCD filters.
142+ *
143+ * @values:
144+ * FT_LCD_FILTER_NONE ::
145+ * Do not perform filtering. When used with subpixel rendering, this
146+ * results in sometimes severe color fringes.
147+ *
148+ * FT_LCD_FILTER_DEFAULT ::
149+ * The default filter reduces color fringes considerably, at the cost
150+ * of a slight blurriness in the output.
151+ *
152+ * It is a beveled, normalized, and color-balanced five-tap filter
153+ * that is more forgiving to screens with non-ideal gamma curves and
154+ * viewing angles. Note that while color-fringing is reduced, it can
155+ * only be minimized by using linear alpha blending and gamma
156+ * correction to render glyphs onto surfaces. The default filter
157+ * weights are [0x08 0x4D 0x56 0x4D 0x08].
158+ *
159+ * FT_LCD_FILTER_LIGHT ::
160+ * The light filter is a variant that is sharper at the cost of
161+ * slightly more color fringes than the default one.
162+ *
163+ * It is a boxy, normalized, and color-balanced three-tap filter that
164+ * is less forgiving to screens with non-ideal gamma curves and
165+ * viewing angles. This filter works best when the rendering system
166+ * uses linear alpha blending and gamma correction to render glyphs
167+ * onto surfaces. The light filter weights are
168+ * [0x00 0x55 0x56 0x55 0x00].
169+ *
170+ * FT_LCD_FILTER_LEGACY ::
171+ * This filter corresponds to the original libXft color filter. It
172+ * provides high contrast output but can exhibit really bad color
173+ * fringes if glyphs are not extremely well hinted to the pixel grid.
174+ * In other words, it only works well if the TrueType bytecode
175+ * interpreter is enabled *and* high-quality hinted fonts are used.
176+ *
177+ * This filter is only provided for comparison purposes, and might be
178+ * disabled or stay unsupported in the future.
179+ *
180+ * FT_LCD_FILTER_LEGACY1 ::
181+ * For historical reasons, the FontConfig library returns a different
182+ * enumeration value for legacy LCD filtering. To make code work that
183+ * (incorrectly) forwards FontConfig's enumeration value to
184+ * @FT_Library_SetLcdFilter without proper mapping, it is thus easiest
185+ * to have another enumeration value, which is completely equal to
186+ * `FT_LCD_FILTER_LEGACY'.
187+ *
188+ * @since:
189+ * 2.3.0 (`FT_LCD_FILTER_LEGACY1' since 2.6.2)
190+ */
191+ typedef enum FT_LcdFilter_
192+ {
193+ FT_LCD_FILTER_NONE = 0,
194+ FT_LCD_FILTER_DEFAULT = 1,
195+ FT_LCD_FILTER_LIGHT = 2,
196+ FT_LCD_FILTER_LEGACY1 = 3,
197+ FT_LCD_FILTER_LEGACY = 16,
198+
199+ FT_LCD_FILTER_MAX /* do not remove */
200+
201+ } FT_LcdFilter;
202+
203+
204+ /**************************************************************************
205+ *
206+ * @func:
207+ * FT_Library_SetLcdFilter
208+ *
209+ * @description:
210+ * This function is used to apply color filtering to LCD decimated
211+ * bitmaps, like the ones used when calling @FT_Render_Glyph with
212+ * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V.
213+ *
214+ * @input:
215+ * library ::
216+ * A handle to the target library instance.
217+ *
218+ * filter ::
219+ * The filter type.
220+ *
221+ * You can use @FT_LCD_FILTER_NONE here to disable this feature, or
222+ * @FT_LCD_FILTER_DEFAULT to use a default filter that should work
223+ * well on most LCD screens.
224+ *
225+ * @return:
226+ * FreeType error code. 0~means success.
227+ *
228+ * @note:
229+ * This feature is always disabled by default. Clients must make an
230+ * explicit call to this function with a `filter' value other than
231+ * @FT_LCD_FILTER_NONE in order to enable it.
232+ *
233+ * Due to *PATENTS* covering subpixel rendering, this function doesn't
234+ * do anything except returning `FT_Err_Unimplemented_Feature' if the
235+ * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
236+ * defined in your build of the library, which should correspond to all
237+ * default builds of FreeType.
238+ *
239+ * @since:
240+ * 2.3.0
241+ */
242+ FT_EXPORT( FT_Error )
243+ FT_Library_SetLcdFilter( FT_Library library,
244+ FT_LcdFilter filter );
245+
246+
247+ /**************************************************************************
248+ *
249+ * @func:
250+ * FT_Library_SetLcdFilterWeights
251+ *
252+ * @description:
253+ * This function can be used to enable LCD filter with custom weights,
254+ * instead of using presets in @FT_Library_SetLcdFilter.
255+ *
256+ * @input:
257+ * library ::
258+ * A handle to the target library instance.
259+ *
260+ * weights ::
261+ * A pointer to an array; the function copies the first five bytes and
262+ * uses them to specify the filter weights.
263+ *
264+ * @return:
265+ * FreeType error code. 0~means success.
266+ *
267+ * @note:
268+ * Due to *PATENTS* covering subpixel rendering, this function doesn't
269+ * do anything except returning `FT_Err_Unimplemented_Feature' if the
270+ * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
271+ * defined in your build of the library, which should correspond to all
272+ * default builds of FreeType.
273+ *
274+ * LCD filter weights can also be set per face using @FT_Face_Properties
275+ * with @FT_PARAM_TAG_LCD_FILTER_WEIGHTS.
276+ *
277+ * @since:
278+ * 2.4.0
279+ */
280+ FT_EXPORT( FT_Error )
281+ FT_Library_SetLcdFilterWeights( FT_Library library,
282+ unsigned char *weights );
283+
284+
285+ /*
286+ * @type:
287+ * FT_LcdFiveTapFilter
288+ *
289+ * @description:
290+ * A typedef for passing the five LCD filter weights to
291+ * @FT_Face_Properties within an @FT_Parameter structure.
292+ *
293+ * @since:
294+ * 2.8
295+ *
296+ */
297+#define FT_LCD_FILTER_FIVE_TAPS 5
298+
299+ typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS];
300+
301+
302+ /* */
303+
304+
305+FT_END_HEADER
306+
307+#endif /* FTLCDFIL_H_ */
308+
309+
310+/* END */
1@@ -0,0 +1,276 @@
2+/***************************************************************************/
3+/* */
4+/* ftlist.h */
5+/* */
6+/* Generic list support for FreeType (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+ /*************************************************************************/
21+ /* */
22+ /* This file implements functions relative to list processing. Its */
23+ /* data structures are defined in `freetype.h'. */
24+ /* */
25+ /*************************************************************************/
26+
27+
28+#ifndef FTLIST_H_
29+#define FTLIST_H_
30+
31+
32+#include <ft2build.h>
33+#include FT_FREETYPE_H
34+
35+#ifdef FREETYPE_H
36+#error "freetype.h of FreeType 1 has been loaded!"
37+#error "Please fix the directory search order for header files"
38+#error "so that freetype.h of FreeType 2 is found first."
39+#endif
40+
41+
42+FT_BEGIN_HEADER
43+
44+
45+ /*************************************************************************/
46+ /* */
47+ /* <Section> */
48+ /* list_processing */
49+ /* */
50+ /* <Title> */
51+ /* List Processing */
52+ /* */
53+ /* <Abstract> */
54+ /* Simple management of lists. */
55+ /* */
56+ /* <Description> */
57+ /* This section contains various definitions related to list */
58+ /* processing using doubly-linked nodes. */
59+ /* */
60+ /* <Order> */
61+ /* FT_List */
62+ /* FT_ListNode */
63+ /* FT_ListRec */
64+ /* FT_ListNodeRec */
65+ /* */
66+ /* FT_List_Add */
67+ /* FT_List_Insert */
68+ /* FT_List_Find */
69+ /* FT_List_Remove */
70+ /* FT_List_Up */
71+ /* FT_List_Iterate */
72+ /* FT_List_Iterator */
73+ /* FT_List_Finalize */
74+ /* FT_List_Destructor */
75+ /* */
76+ /*************************************************************************/
77+
78+
79+ /*************************************************************************/
80+ /* */
81+ /* <Function> */
82+ /* FT_List_Find */
83+ /* */
84+ /* <Description> */
85+ /* Find the list node for a given listed object. */
86+ /* */
87+ /* <Input> */
88+ /* list :: A pointer to the parent list. */
89+ /* data :: The address of the listed object. */
90+ /* */
91+ /* <Return> */
92+ /* List node. NULL if it wasn't found. */
93+ /* */
94+ FT_EXPORT( FT_ListNode )
95+ FT_List_Find( FT_List list,
96+ void* data );
97+
98+
99+ /*************************************************************************/
100+ /* */
101+ /* <Function> */
102+ /* FT_List_Add */
103+ /* */
104+ /* <Description> */
105+ /* Append an element to the end of a list. */
106+ /* */
107+ /* <InOut> */
108+ /* list :: A pointer to the parent list. */
109+ /* node :: The node to append. */
110+ /* */
111+ FT_EXPORT( void )
112+ FT_List_Add( FT_List list,
113+ FT_ListNode node );
114+
115+
116+ /*************************************************************************/
117+ /* */
118+ /* <Function> */
119+ /* FT_List_Insert */
120+ /* */
121+ /* <Description> */
122+ /* Insert an element at the head of a list. */
123+ /* */
124+ /* <InOut> */
125+ /* list :: A pointer to parent list. */
126+ /* node :: The node to insert. */
127+ /* */
128+ FT_EXPORT( void )
129+ FT_List_Insert( FT_List list,
130+ FT_ListNode node );
131+
132+
133+ /*************************************************************************/
134+ /* */
135+ /* <Function> */
136+ /* FT_List_Remove */
137+ /* */
138+ /* <Description> */
139+ /* Remove a node from a list. This function doesn't check whether */
140+ /* the node is in the list! */
141+ /* */
142+ /* <Input> */
143+ /* node :: The node to remove. */
144+ /* */
145+ /* <InOut> */
146+ /* list :: A pointer to the parent list. */
147+ /* */
148+ FT_EXPORT( void )
149+ FT_List_Remove( FT_List list,
150+ FT_ListNode node );
151+
152+
153+ /*************************************************************************/
154+ /* */
155+ /* <Function> */
156+ /* FT_List_Up */
157+ /* */
158+ /* <Description> */
159+ /* Move a node to the head/top of a list. Used to maintain LRU */
160+ /* lists. */
161+ /* */
162+ /* <InOut> */
163+ /* list :: A pointer to the parent list. */
164+ /* node :: The node to move. */
165+ /* */
166+ FT_EXPORT( void )
167+ FT_List_Up( FT_List list,
168+ FT_ListNode node );
169+
170+
171+ /*************************************************************************/
172+ /* */
173+ /* <FuncType> */
174+ /* FT_List_Iterator */
175+ /* */
176+ /* <Description> */
177+ /* An FT_List iterator function that is called during a list parse */
178+ /* by @FT_List_Iterate. */
179+ /* */
180+ /* <Input> */
181+ /* node :: The current iteration list node. */
182+ /* */
183+ /* user :: A typeless pointer passed to @FT_List_Iterate. */
184+ /* Can be used to point to the iteration's state. */
185+ /* */
186+ typedef FT_Error
187+ (*FT_List_Iterator)( FT_ListNode node,
188+ void* user );
189+
190+
191+ /*************************************************************************/
192+ /* */
193+ /* <Function> */
194+ /* FT_List_Iterate */
195+ /* */
196+ /* <Description> */
197+ /* Parse a list and calls a given iterator function on each element. */
198+ /* Note that parsing is stopped as soon as one of the iterator calls */
199+ /* returns a non-zero value. */
200+ /* */
201+ /* <Input> */
202+ /* list :: A handle to the list. */
203+ /* iterator :: An iterator function, called on each node of the list. */
204+ /* user :: A user-supplied field that is passed as the second */
205+ /* argument to the iterator. */
206+ /* */
207+ /* <Return> */
208+ /* The result (a FreeType error code) of the last iterator call. */
209+ /* */
210+ FT_EXPORT( FT_Error )
211+ FT_List_Iterate( FT_List list,
212+ FT_List_Iterator iterator,
213+ void* user );
214+
215+
216+ /*************************************************************************/
217+ /* */
218+ /* <FuncType> */
219+ /* FT_List_Destructor */
220+ /* */
221+ /* <Description> */
222+ /* An @FT_List iterator function that is called during a list */
223+ /* finalization by @FT_List_Finalize to destroy all elements in a */
224+ /* given list. */
225+ /* */
226+ /* <Input> */
227+ /* system :: The current system object. */
228+ /* */
229+ /* data :: The current object to destroy. */
230+ /* */
231+ /* user :: A typeless pointer passed to @FT_List_Iterate. It can */
232+ /* be used to point to the iteration's state. */
233+ /* */
234+ typedef void
235+ (*FT_List_Destructor)( FT_Memory memory,
236+ void* data,
237+ void* user );
238+
239+
240+ /*************************************************************************/
241+ /* */
242+ /* <Function> */
243+ /* FT_List_Finalize */
244+ /* */
245+ /* <Description> */
246+ /* Destroy all elements in the list as well as the list itself. */
247+ /* */
248+ /* <Input> */
249+ /* list :: A handle to the list. */
250+ /* */
251+ /* destroy :: A list destructor that will be applied to each element */
252+ /* of the list. Set this to NULL if not needed. */
253+ /* */
254+ /* memory :: The current memory object that handles deallocation. */
255+ /* */
256+ /* user :: A user-supplied field that is passed as the last */
257+ /* argument to the destructor. */
258+ /* */
259+ /* <Note> */
260+ /* This function expects that all nodes added by @FT_List_Add or */
261+ /* @FT_List_Insert have been dynamically allocated. */
262+ /* */
263+ FT_EXPORT( void )
264+ FT_List_Finalize( FT_List list,
265+ FT_List_Destructor destroy,
266+ FT_Memory memory,
267+ void* user );
268+
269+ /* */
270+
271+
272+FT_END_HEADER
273+
274+#endif /* FTLIST_H_ */
275+
276+
277+/* END */
1@@ -0,0 +1,99 @@
2+/***************************************************************************/
3+/* */
4+/* ftlzw.h */
5+/* */
6+/* LZW-compressed stream support. */
7+/* */
8+/* Copyright 2004-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTLZW_H_
21+#define FTLZW_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+ /*************************************************************************/
36+ /* */
37+ /* <Section> */
38+ /* lzw */
39+ /* */
40+ /* <Title> */
41+ /* LZW Streams */
42+ /* */
43+ /* <Abstract> */
44+ /* Using LZW-compressed font files. */
45+ /* */
46+ /* <Description> */
47+ /* This section contains the declaration of LZW-specific functions. */
48+ /* */
49+ /*************************************************************************/
50+
51+ /************************************************************************
52+ *
53+ * @function:
54+ * FT_Stream_OpenLZW
55+ *
56+ * @description:
57+ * Open a new stream to parse LZW-compressed font files. This is
58+ * mainly used to support the compressed `*.pcf.Z' fonts that come
59+ * with XFree86.
60+ *
61+ * @input:
62+ * stream :: The target embedding stream.
63+ *
64+ * source :: The source stream.
65+ *
66+ * @return:
67+ * FreeType error code. 0~means success.
68+ *
69+ * @note:
70+ * The source stream must be opened _before_ calling this function.
71+ *
72+ * Calling the internal function `FT_Stream_Close' on the new stream will
73+ * *not* call `FT_Stream_Close' on the source stream. None of the stream
74+ * objects will be released to the heap.
75+ *
76+ * The stream implementation is very basic and resets the decompression
77+ * process each time seeking backwards is needed within the stream
78+ *
79+ * In certain builds of the library, LZW compression recognition is
80+ * automatically handled when calling @FT_New_Face or @FT_Open_Face.
81+ * This means that if no font driver is capable of handling the raw
82+ * compressed file, the library will try to open a LZW stream from it
83+ * and re-open the face with it.
84+ *
85+ * This function may return `FT_Err_Unimplemented_Feature' if your build
86+ * of FreeType was not compiled with LZW support.
87+ */
88+ FT_EXPORT( FT_Error )
89+ FT_Stream_OpenLZW( FT_Stream stream,
90+ FT_Stream source );
91+
92+ /* */
93+
94+
95+FT_END_HEADER
96+
97+#endif /* FTLZW_H_ */
98+
99+
100+/* END */
+275,
-0
1@@ -0,0 +1,275 @@
2+/***************************************************************************/
3+/* */
4+/* ftmac.h */
5+/* */
6+/* Additional Mac-specific API. */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+/***************************************************************************/
21+/* */
22+/* NOTE: Include this file after FT_FREETYPE_H and after any */
23+/* Mac-specific headers (because this header uses Mac types such as */
24+/* Handle, FSSpec, FSRef, etc.) */
25+/* */
26+/***************************************************************************/
27+
28+
29+#ifndef FTMAC_H_
30+#define FTMAC_H_
31+
32+
33+#include <ft2build.h>
34+
35+
36+FT_BEGIN_HEADER
37+
38+
39+ /* gcc-3.1 and later can warn about functions tagged as deprecated */
40+#ifndef FT_DEPRECATED_ATTRIBUTE
41+#if defined( __GNUC__ ) && \
42+ ( ( __GNUC__ >= 4 ) || \
43+ ( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 1 ) ) )
44+#define FT_DEPRECATED_ATTRIBUTE __attribute__(( deprecated ))
45+#else
46+#define FT_DEPRECATED_ATTRIBUTE
47+#endif
48+#endif
49+
50+
51+ /*************************************************************************/
52+ /* */
53+ /* <Section> */
54+ /* mac_specific */
55+ /* */
56+ /* <Title> */
57+ /* Mac Specific Interface */
58+ /* */
59+ /* <Abstract> */
60+ /* Only available on the Macintosh. */
61+ /* */
62+ /* <Description> */
63+ /* The following definitions are only available if FreeType is */
64+ /* compiled on a Macintosh. */
65+ /* */
66+ /*************************************************************************/
67+
68+
69+ /*************************************************************************/
70+ /* */
71+ /* <Function> */
72+ /* FT_New_Face_From_FOND */
73+ /* */
74+ /* <Description> */
75+ /* Create a new face object from a FOND resource. */
76+ /* */
77+ /* <InOut> */
78+ /* library :: A handle to the library resource. */
79+ /* */
80+ /* <Input> */
81+ /* fond :: A FOND resource. */
82+ /* */
83+ /* face_index :: Only supported for the -1 `sanity check' special */
84+ /* case. */
85+ /* */
86+ /* <Output> */
87+ /* aface :: A handle to a new face object. */
88+ /* */
89+ /* <Return> */
90+ /* FreeType error code. 0~means success. */
91+ /* */
92+ /* <Notes> */
93+ /* This function can be used to create @FT_Face objects from fonts */
94+ /* that are installed in the system as follows. */
95+ /* */
96+ /* { */
97+ /* fond = GetResource( 'FOND', fontName ); */
98+ /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */
99+ /* } */
100+ /* */
101+ FT_EXPORT( FT_Error )
102+ FT_New_Face_From_FOND( FT_Library library,
103+ Handle fond,
104+ FT_Long face_index,
105+ FT_Face *aface )
106+ FT_DEPRECATED_ATTRIBUTE;
107+
108+
109+ /*************************************************************************/
110+ /* */
111+ /* <Function> */
112+ /* FT_GetFile_From_Mac_Name */
113+ /* */
114+ /* <Description> */
115+ /* Return an FSSpec for the disk file containing the named font. */
116+ /* */
117+ /* <Input> */
118+ /* fontName :: Mac OS name of the font (e.g., Times New Roman */
119+ /* Bold). */
120+ /* */
121+ /* <Output> */
122+ /* pathSpec :: FSSpec to the file. For passing to */
123+ /* @FT_New_Face_From_FSSpec. */
124+ /* */
125+ /* face_index :: Index of the face. For passing to */
126+ /* @FT_New_Face_From_FSSpec. */
127+ /* */
128+ /* <Return> */
129+ /* FreeType error code. 0~means success. */
130+ /* */
131+ FT_EXPORT( FT_Error )
132+ FT_GetFile_From_Mac_Name( const char* fontName,
133+ FSSpec* pathSpec,
134+ FT_Long* face_index )
135+ FT_DEPRECATED_ATTRIBUTE;
136+
137+
138+ /*************************************************************************/
139+ /* */
140+ /* <Function> */
141+ /* FT_GetFile_From_Mac_ATS_Name */
142+ /* */
143+ /* <Description> */
144+ /* Return an FSSpec for the disk file containing the named font. */
145+ /* */
146+ /* <Input> */
147+ /* fontName :: Mac OS name of the font in ATS framework. */
148+ /* */
149+ /* <Output> */
150+ /* pathSpec :: FSSpec to the file. For passing to */
151+ /* @FT_New_Face_From_FSSpec. */
152+ /* */
153+ /* face_index :: Index of the face. For passing to */
154+ /* @FT_New_Face_From_FSSpec. */
155+ /* */
156+ /* <Return> */
157+ /* FreeType error code. 0~means success. */
158+ /* */
159+ FT_EXPORT( FT_Error )
160+ FT_GetFile_From_Mac_ATS_Name( const char* fontName,
161+ FSSpec* pathSpec,
162+ FT_Long* face_index )
163+ FT_DEPRECATED_ATTRIBUTE;
164+
165+
166+ /*************************************************************************/
167+ /* */
168+ /* <Function> */
169+ /* FT_GetFilePath_From_Mac_ATS_Name */
170+ /* */
171+ /* <Description> */
172+ /* Return a pathname of the disk file and face index for given font */
173+ /* name that is handled by ATS framework. */
174+ /* */
175+ /* <Input> */
176+ /* fontName :: Mac OS name of the font in ATS framework. */
177+ /* */
178+ /* <Output> */
179+ /* path :: Buffer to store pathname of the file. For passing */
180+ /* to @FT_New_Face. The client must allocate this */
181+ /* buffer before calling this function. */
182+ /* */
183+ /* maxPathSize :: Lengths of the buffer `path' that client allocated. */
184+ /* */
185+ /* face_index :: Index of the face. For passing to @FT_New_Face. */
186+ /* */
187+ /* <Return> */
188+ /* FreeType error code. 0~means success. */
189+ /* */
190+ FT_EXPORT( FT_Error )
191+ FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
192+ UInt8* path,
193+ UInt32 maxPathSize,
194+ FT_Long* face_index )
195+ FT_DEPRECATED_ATTRIBUTE;
196+
197+
198+ /*************************************************************************/
199+ /* */
200+ /* <Function> */
201+ /* FT_New_Face_From_FSSpec */
202+ /* */
203+ /* <Description> */
204+ /* Create a new face object from a given resource and typeface index */
205+ /* using an FSSpec to the font file. */
206+ /* */
207+ /* <InOut> */
208+ /* library :: A handle to the library resource. */
209+ /* */
210+ /* <Input> */
211+ /* spec :: FSSpec to the font file. */
212+ /* */
213+ /* face_index :: The index of the face within the resource. The */
214+ /* first face has index~0. */
215+ /* <Output> */
216+ /* aface :: A handle to a new face object. */
217+ /* */
218+ /* <Return> */
219+ /* FreeType error code. 0~means success. */
220+ /* */
221+ /* <Note> */
222+ /* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */
223+ /* it accepts an FSSpec instead of a path. */
224+ /* */
225+ FT_EXPORT( FT_Error )
226+ FT_New_Face_From_FSSpec( FT_Library library,
227+ const FSSpec *spec,
228+ FT_Long face_index,
229+ FT_Face *aface )
230+ FT_DEPRECATED_ATTRIBUTE;
231+
232+
233+ /*************************************************************************/
234+ /* */
235+ /* <Function> */
236+ /* FT_New_Face_From_FSRef */
237+ /* */
238+ /* <Description> */
239+ /* Create a new face object from a given resource and typeface index */
240+ /* using an FSRef to the font file. */
241+ /* */
242+ /* <InOut> */
243+ /* library :: A handle to the library resource. */
244+ /* */
245+ /* <Input> */
246+ /* spec :: FSRef to the font file. */
247+ /* */
248+ /* face_index :: The index of the face within the resource. The */
249+ /* first face has index~0. */
250+ /* <Output> */
251+ /* aface :: A handle to a new face object. */
252+ /* */
253+ /* <Return> */
254+ /* FreeType error code. 0~means success. */
255+ /* */
256+ /* <Note> */
257+ /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */
258+ /* it accepts an FSRef instead of a path. */
259+ /* */
260+ FT_EXPORT( FT_Error )
261+ FT_New_Face_From_FSRef( FT_Library library,
262+ const FSRef *ref,
263+ FT_Long face_index,
264+ FT_Face *aface )
265+ FT_DEPRECATED_ATTRIBUTE;
266+
267+ /* */
268+
269+
270+FT_END_HEADER
271+
272+
273+#endif /* FTMAC_H_ */
274+
275+
276+/* END */
+638,
-0
1@@ -0,0 +1,638 @@
2+/***************************************************************************/
3+/* */
4+/* ftmm.h */
5+/* */
6+/* FreeType Multiple Master font interface (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTMM_H_
21+#define FTMM_H_
22+
23+
24+#include <ft2build.h>
25+#include FT_TYPE1_TABLES_H
26+
27+
28+FT_BEGIN_HEADER
29+
30+
31+ /*************************************************************************/
32+ /* */
33+ /* <Section> */
34+ /* multiple_masters */
35+ /* */
36+ /* <Title> */
37+ /* Multiple Masters */
38+ /* */
39+ /* <Abstract> */
40+ /* How to manage Multiple Masters fonts. */
41+ /* */
42+ /* <Description> */
43+ /* The following types and functions are used to manage Multiple */
44+ /* Master fonts, i.e., the selection of specific design instances by */
45+ /* setting design axis coordinates. */
46+ /* */
47+ /* Besides Adobe MM fonts, the interface supports Apple's TrueType GX */
48+ /* and OpenType variation fonts. Some of the routines only work with */
49+ /* Adobe MM fonts, others will work with all three types. They are */
50+ /* similar enough that a consistent interface makes sense. */
51+ /* */
52+ /*************************************************************************/
53+
54+
55+ /*************************************************************************/
56+ /* */
57+ /* <Struct> */
58+ /* FT_MM_Axis */
59+ /* */
60+ /* <Description> */
61+ /* A structure to model a given axis in design space for Multiple */
62+ /* Masters fonts. */
63+ /* */
64+ /* This structure can't be used for TrueType GX or OpenType variation */
65+ /* fonts. */
66+ /* */
67+ /* <Fields> */
68+ /* name :: The axis's name. */
69+ /* */
70+ /* minimum :: The axis's minimum design coordinate. */
71+ /* */
72+ /* maximum :: The axis's maximum design coordinate. */
73+ /* */
74+ typedef struct FT_MM_Axis_
75+ {
76+ FT_String* name;
77+ FT_Long minimum;
78+ FT_Long maximum;
79+
80+ } FT_MM_Axis;
81+
82+
83+ /*************************************************************************/
84+ /* */
85+ /* <Struct> */
86+ /* FT_Multi_Master */
87+ /* */
88+ /* <Description> */
89+ /* A structure to model the axes and space of a Multiple Masters */
90+ /* font. */
91+ /* */
92+ /* This structure can't be used for TrueType GX or OpenType variation */
93+ /* fonts. */
94+ /* */
95+ /* <Fields> */
96+ /* num_axis :: Number of axes. Cannot exceed~4. */
97+ /* */
98+ /* num_designs :: Number of designs; should be normally 2^num_axis */
99+ /* even though the Type~1 specification strangely */
100+ /* allows for intermediate designs to be present. */
101+ /* This number cannot exceed~16. */
102+ /* */
103+ /* axis :: A table of axis descriptors. */
104+ /* */
105+ typedef struct FT_Multi_Master_
106+ {
107+ FT_UInt num_axis;
108+ FT_UInt num_designs;
109+ FT_MM_Axis axis[T1_MAX_MM_AXIS];
110+
111+ } FT_Multi_Master;
112+
113+
114+ /*************************************************************************/
115+ /* */
116+ /* <Struct> */
117+ /* FT_Var_Axis */
118+ /* */
119+ /* <Description> */
120+ /* A structure to model a given axis in design space for Multiple */
121+ /* Masters, TrueType GX, and OpenType variation fonts. */
122+ /* */
123+ /* <Fields> */
124+ /* name :: The axis's name. */
125+ /* Not always meaningful for TrueType GX or OpenType */
126+ /* variation fonts. */
127+ /* */
128+ /* minimum :: The axis's minimum design coordinate. */
129+ /* */
130+ /* def :: The axis's default design coordinate. */
131+ /* FreeType computes meaningful default values for Adobe */
132+ /* MM fonts. */
133+ /* */
134+ /* maximum :: The axis's maximum design coordinate. */
135+ /* */
136+ /* tag :: The axis's tag (the equivalent to `name' for TrueType */
137+ /* GX and OpenType variation fonts). FreeType provides */
138+ /* default values for Adobe MM fonts if possible. */
139+ /* */
140+ /* strid :: The axis name entry in the font's `name' table. This */
141+ /* is another (and often better) version of the `name' */
142+ /* field for TrueType GX or OpenType variation fonts. Not */
143+ /* meaningful for Adobe MM fonts. */
144+ /* */
145+ /* <Note> */
146+ /* The fields `minimum', `def', and `maximum' are 16.16 fractional */
147+ /* values for TrueType GX and OpenType variation fonts. For Adobe MM */
148+ /* fonts, the values are integers. */
149+ /* */
150+ typedef struct FT_Var_Axis_
151+ {
152+ FT_String* name;
153+
154+ FT_Fixed minimum;
155+ FT_Fixed def;
156+ FT_Fixed maximum;
157+
158+ FT_ULong tag;
159+ FT_UInt strid;
160+
161+ } FT_Var_Axis;
162+
163+
164+ /*************************************************************************/
165+ /* */
166+ /* <Struct> */
167+ /* FT_Var_Named_Style */
168+ /* */
169+ /* <Description> */
170+ /* A structure to model a named instance in a TrueType GX or OpenType */
171+ /* variation font. */
172+ /* */
173+ /* This structure can't be used for Adobe MM fonts. */
174+ /* */
175+ /* <Fields> */
176+ /* coords :: The design coordinates for this instance. */
177+ /* This is an array with one entry for each axis. */
178+ /* */
179+ /* strid :: The entry in `name' table identifying this instance. */
180+ /* */
181+ /* psid :: The entry in `name' table identifying a PostScript name */
182+ /* for this instance. Value 0xFFFF indicates a missing */
183+ /* entry. */
184+ /* */
185+ typedef struct FT_Var_Named_Style_
186+ {
187+ FT_Fixed* coords;
188+ FT_UInt strid;
189+ FT_UInt psid; /* since 2.7.1 */
190+
191+ } FT_Var_Named_Style;
192+
193+
194+ /*************************************************************************/
195+ /* */
196+ /* <Struct> */
197+ /* FT_MM_Var */
198+ /* */
199+ /* <Description> */
200+ /* A structure to model the axes and space of an Adobe MM, TrueType */
201+ /* GX, or OpenType variation font. */
202+ /* */
203+ /* Some fields are specific to one format and not to the others. */
204+ /* */
205+ /* <Fields> */
206+ /* num_axis :: The number of axes. The maximum value is~4 for */
207+ /* Adobe MM fonts; no limit in TrueType GX or */
208+ /* OpenType variation fonts. */
209+ /* */
210+ /* num_designs :: The number of designs; should be normally */
211+ /* 2^num_axis for Adobe MM fonts. Not meaningful */
212+ /* for TrueType GX or OpenType variation fonts */
213+ /* (where every glyph could have a different */
214+ /* number of designs). */
215+ /* */
216+ /* num_namedstyles :: The number of named styles; a `named style' is */
217+ /* a tuple of design coordinates that has a string */
218+ /* ID (in the `name' table) associated with it. */
219+ /* The font can tell the user that, for example, */
220+ /* [Weight=1.5,Width=1.1] is `Bold'. Another name */
221+ /* for `named style' is `named instance'. */
222+ /* */
223+ /* For Adobe Multiple Masters fonts, this value is */
224+ /* always zero because the format does not support */
225+ /* named styles. */
226+ /* */
227+ /* axis :: An axis descriptor table. */
228+ /* TrueType GX and OpenType variation fonts */
229+ /* contain slightly more data than Adobe MM fonts. */
230+ /* Memory management of this pointer is done */
231+ /* internally by FreeType. */
232+ /* */
233+ /* namedstyle :: A named style (instance) table. */
234+ /* Only meaningful for TrueType GX and OpenType */
235+ /* variation fonts. Memory management of this */
236+ /* pointer is done internally by FreeType. */
237+ /* */
238+ typedef struct FT_MM_Var_
239+ {
240+ FT_UInt num_axis;
241+ FT_UInt num_designs;
242+ FT_UInt num_namedstyles;
243+ FT_Var_Axis* axis;
244+ FT_Var_Named_Style* namedstyle;
245+
246+ } FT_MM_Var;
247+
248+
249+ /*************************************************************************/
250+ /* */
251+ /* <Function> */
252+ /* FT_Get_Multi_Master */
253+ /* */
254+ /* <Description> */
255+ /* Retrieve a variation descriptor of a given Adobe MM font. */
256+ /* */
257+ /* This function can't be used with TrueType GX or OpenType variation */
258+ /* fonts. */
259+ /* */
260+ /* <Input> */
261+ /* face :: A handle to the source face. */
262+ /* */
263+ /* <Output> */
264+ /* amaster :: The Multiple Masters descriptor. */
265+ /* */
266+ /* <Return> */
267+ /* FreeType error code. 0~means success. */
268+ /* */
269+ FT_EXPORT( FT_Error )
270+ FT_Get_Multi_Master( FT_Face face,
271+ FT_Multi_Master *amaster );
272+
273+
274+ /*************************************************************************/
275+ /* */
276+ /* <Function> */
277+ /* FT_Get_MM_Var */
278+ /* */
279+ /* <Description> */
280+ /* Retrieve a variation descriptor for a given font. */
281+ /* */
282+ /* This function works with all supported variation formats. */
283+ /* */
284+ /* <Input> */
285+ /* face :: A handle to the source face. */
286+ /* */
287+ /* <Output> */
288+ /* amaster :: The variation descriptor. */
289+ /* Allocates a data structure, which the user must */
290+ /* deallocate with a call to @FT_Done_MM_Var after use. */
291+ /* */
292+ /* <Return> */
293+ /* FreeType error code. 0~means success. */
294+ /* */
295+ FT_EXPORT( FT_Error )
296+ FT_Get_MM_Var( FT_Face face,
297+ FT_MM_Var* *amaster );
298+
299+
300+ /*************************************************************************/
301+ /* */
302+ /* <Function> */
303+ /* FT_Done_MM_Var */
304+ /* */
305+ /* <Description> */
306+ /* Free the memory allocated by @FT_Get_MM_Var. */
307+ /* */
308+ /* <Input> */
309+ /* library :: A handle of the face's parent library object that was */
310+ /* used in the call to @FT_Get_MM_Var to create `amaster'. */
311+ /* */
312+ /* <Return> */
313+ /* FreeType error code. 0~means success. */
314+ /* */
315+ FT_EXPORT( FT_Error )
316+ FT_Done_MM_Var( FT_Library library,
317+ FT_MM_Var *amaster );
318+
319+
320+ /*************************************************************************/
321+ /* */
322+ /* <Function> */
323+ /* FT_Set_MM_Design_Coordinates */
324+ /* */
325+ /* <Description> */
326+ /* For Adobe MM fonts, choose an interpolated font design through */
327+ /* design coordinates. */
328+ /* */
329+ /* This function can't be used with TrueType GX or OpenType variation */
330+ /* fonts. */
331+ /* */
332+ /* <InOut> */
333+ /* face :: A handle to the source face. */
334+ /* */
335+ /* <Input> */
336+ /* num_coords :: The number of available design coordinates. If it */
337+ /* is larger than the number of axes, ignore the excess */
338+ /* values. If it is smaller than the number of axes, */
339+ /* use default values for the remaining axes. */
340+ /* */
341+ /* coords :: An array of design coordinates. */
342+ /* */
343+ /* <Return> */
344+ /* FreeType error code. 0~means success. */
345+ /* */
346+ /* <Note> */
347+ /* [Since 2.8.1] To reset all axes to the default values, call the */
348+ /* function with `num_coords' set to zero and `coords' set to NULL. */
349+ /* */
350+ /* [Since 2.9] If `num_coords' is larger than zero, this function */
351+ /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */
352+ /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */
353+ /* is zero, this bit flag gets unset. */
354+ /* */
355+ FT_EXPORT( FT_Error )
356+ FT_Set_MM_Design_Coordinates( FT_Face face,
357+ FT_UInt num_coords,
358+ FT_Long* coords );
359+
360+
361+ /*************************************************************************/
362+ /* */
363+ /* <Function> */
364+ /* FT_Set_Var_Design_Coordinates */
365+ /* */
366+ /* <Description> */
367+ /* Choose an interpolated font design through design coordinates. */
368+ /* */
369+ /* This function works with all supported variation formats. */
370+ /* */
371+ /* <InOut> */
372+ /* face :: A handle to the source face. */
373+ /* */
374+ /* <Input> */
375+ /* num_coords :: The number of available design coordinates. If it */
376+ /* is larger than the number of axes, ignore the excess */
377+ /* values. If it is smaller than the number of axes, */
378+ /* use default values for the remaining axes. */
379+ /* */
380+ /* coords :: An array of design coordinates. */
381+ /* */
382+ /* <Return> */
383+ /* FreeType error code. 0~means success. */
384+ /* */
385+ /* <Note> */
386+ /* [Since 2.8.1] To reset all axes to the default values, call the */
387+ /* function with `num_coords' set to zero and `coords' set to NULL. */
388+ /* [Since 2.9] `Default values' means the currently selected named */
389+ /* instance (or the base font if no named instance is selected). */
390+ /* */
391+ /* [Since 2.9] If `num_coords' is larger than zero, this function */
392+ /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */
393+ /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */
394+ /* is zero, this bit flag gets unset. */
395+ /* */
396+ FT_EXPORT( FT_Error )
397+ FT_Set_Var_Design_Coordinates( FT_Face face,
398+ FT_UInt num_coords,
399+ FT_Fixed* coords );
400+
401+
402+ /*************************************************************************/
403+ /* */
404+ /* <Function> */
405+ /* FT_Get_Var_Design_Coordinates */
406+ /* */
407+ /* <Description> */
408+ /* Get the design coordinates of the currently selected interpolated */
409+ /* font. */
410+ /* */
411+ /* This function works with all supported variation formats. */
412+ /* */
413+ /* <Input> */
414+ /* face :: A handle to the source face. */
415+ /* */
416+ /* num_coords :: The number of design coordinates to retrieve. If it */
417+ /* is larger than the number of axes, set the excess */
418+ /* values to~0. */
419+ /* */
420+ /* <Output> */
421+ /* coords :: The design coordinates array. */
422+ /* */
423+ /* <Return> */
424+ /* FreeType error code. 0~means success. */
425+ /* */
426+ /* <Since> */
427+ /* 2.7.1 */
428+ /* */
429+ FT_EXPORT( FT_Error )
430+ FT_Get_Var_Design_Coordinates( FT_Face face,
431+ FT_UInt num_coords,
432+ FT_Fixed* coords );
433+
434+
435+ /*************************************************************************/
436+ /* */
437+ /* <Function> */
438+ /* FT_Set_MM_Blend_Coordinates */
439+ /* */
440+ /* <Description> */
441+ /* Choose an interpolated font design through normalized blend */
442+ /* coordinates. */
443+ /* */
444+ /* This function works with all supported variation formats. */
445+ /* */
446+ /* <InOut> */
447+ /* face :: A handle to the source face. */
448+ /* */
449+ /* <Input> */
450+ /* num_coords :: The number of available design coordinates. If it */
451+ /* is larger than the number of axes, ignore the excess */
452+ /* values. If it is smaller than the number of axes, */
453+ /* use default values for the remaining axes. */
454+ /* */
455+ /* coords :: The design coordinates array (each element must be */
456+ /* between 0 and 1.0 for Adobe MM fonts, and between */
457+ /* -1.0 and 1.0 for TrueType GX and OpenType variation */
458+ /* fonts). */
459+ /* */
460+ /* <Return> */
461+ /* FreeType error code. 0~means success. */
462+ /* */
463+ /* <Note> */
464+ /* [Since 2.8.1] To reset all axes to the default values, call the */
465+ /* function with `num_coords' set to zero and `coords' set to NULL. */
466+ /* [Since 2.9] `Default values' means the currently selected named */
467+ /* instance (or the base font if no named instance is selected). */
468+ /* */
469+ /* [Since 2.9] If `num_coords' is larger than zero, this function */
470+ /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */
471+ /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */
472+ /* is zero, this bit flag gets unset. */
473+ /* */
474+ FT_EXPORT( FT_Error )
475+ FT_Set_MM_Blend_Coordinates( FT_Face face,
476+ FT_UInt num_coords,
477+ FT_Fixed* coords );
478+
479+
480+ /*************************************************************************/
481+ /* */
482+ /* <Function> */
483+ /* FT_Get_MM_Blend_Coordinates */
484+ /* */
485+ /* <Description> */
486+ /* Get the normalized blend coordinates of the currently selected */
487+ /* interpolated font. */
488+ /* */
489+ /* This function works with all supported variation formats. */
490+ /* */
491+ /* <Input> */
492+ /* face :: A handle to the source face. */
493+ /* */
494+ /* num_coords :: The number of normalized blend coordinates to */
495+ /* retrieve. If it is larger than the number of axes, */
496+ /* set the excess values to~0.5 for Adobe MM fonts, and */
497+ /* to~0 for TrueType GX and OpenType variation fonts. */
498+ /* */
499+ /* <Output> */
500+ /* coords :: The normalized blend coordinates array. */
501+ /* */
502+ /* <Return> */
503+ /* FreeType error code. 0~means success. */
504+ /* */
505+ /* <Since> */
506+ /* 2.7.1 */
507+ /* */
508+ FT_EXPORT( FT_Error )
509+ FT_Get_MM_Blend_Coordinates( FT_Face face,
510+ FT_UInt num_coords,
511+ FT_Fixed* coords );
512+
513+
514+ /*************************************************************************/
515+ /* */
516+ /* <Function> */
517+ /* FT_Set_Var_Blend_Coordinates */
518+ /* */
519+ /* <Description> */
520+ /* This is another name of @FT_Set_MM_Blend_Coordinates. */
521+ /* */
522+ FT_EXPORT( FT_Error )
523+ FT_Set_Var_Blend_Coordinates( FT_Face face,
524+ FT_UInt num_coords,
525+ FT_Fixed* coords );
526+
527+
528+ /*************************************************************************/
529+ /* */
530+ /* <Function> */
531+ /* FT_Get_Var_Blend_Coordinates */
532+ /* */
533+ /* <Description> */
534+ /* This is another name of @FT_Get_MM_Blend_Coordinates. */
535+ /* */
536+ /* <Since> */
537+ /* 2.7.1 */
538+ /* */
539+ FT_EXPORT( FT_Error )
540+ FT_Get_Var_Blend_Coordinates( FT_Face face,
541+ FT_UInt num_coords,
542+ FT_Fixed* coords );
543+
544+
545+ /*************************************************************************/
546+ /* */
547+ /* <Enum> */
548+ /* FT_VAR_AXIS_FLAG_XXX */
549+ /* */
550+ /* <Description> */
551+ /* A list of bit flags used in the return value of */
552+ /* @FT_Get_Var_Axis_Flags. */
553+ /* */
554+ /* <Values> */
555+ /* FT_VAR_AXIS_FLAG_HIDDEN :: */
556+ /* The variation axis should not be exposed to user interfaces. */
557+ /* */
558+ /* <Since> */
559+ /* 2.8.1 */
560+ /* */
561+#define FT_VAR_AXIS_FLAG_HIDDEN 1
562+
563+
564+ /*************************************************************************/
565+ /* */
566+ /* <Function> */
567+ /* FT_Get_Var_Axis_Flags */
568+ /* */
569+ /* <Description> */
570+ /* Get the `flags' field of an OpenType Variation Axis Record. */
571+ /* */
572+ /* Not meaningful for Adobe MM fonts (`*flags' is always zero). */
573+ /* */
574+ /* <Input> */
575+ /* master :: The variation descriptor. */
576+ /* */
577+ /* axis_index :: The index of the requested variation axis. */
578+ /* */
579+ /* <Output> */
580+ /* flags :: The `flags' field. See @FT_VAR_AXIS_FLAG_XXX for */
581+ /* possible values. */
582+ /* */
583+ /* <Return> */
584+ /* FreeType error code. 0~means success. */
585+ /* */
586+ /* <Since> */
587+ /* 2.8.1 */
588+ /* */
589+ FT_EXPORT( FT_Error )
590+ FT_Get_Var_Axis_Flags( FT_MM_Var* master,
591+ FT_UInt axis_index,
592+ FT_UInt* flags );
593+
594+
595+ /*************************************************************************/
596+ /* */
597+ /* <Function> */
598+ /* FT_Set_Named_Instance */
599+ /* */
600+ /* <Description> */
601+ /* Set or change the current named instance. */
602+ /* */
603+ /* <Input> */
604+ /* face :: A handle to the source face. */
605+ /* */
606+ /* instance_index :: The index of the requested instance, starting */
607+ /* with value 1. If set to value 0, FreeType */
608+ /* switches to font access without a named */
609+ /* instance. */
610+ /* */
611+ /* <Return> */
612+ /* FreeType error code. 0~means success. */
613+ /* */
614+ /* <Note> */
615+ /* The function uses the value of `instance_index' to set bits 16-30 */
616+ /* of the face's `face_index' field. It also resets any variation */
617+ /* applied to the font, and the @FT_FACE_FLAG_VARIATION bit of the */
618+ /* face's `face_flags' field gets reset to zero (i.e., */
619+ /* @FT_IS_VARIATION will return false). */
620+ /* */
621+ /* For Adobe MM fonts (which don't have named instances) this */
622+ /* function simply resets the current face to the default instance. */
623+ /* */
624+ /* <Since> */
625+ /* 2.9 */
626+ /* */
627+ FT_EXPORT( FT_Error )
628+ FT_Set_Named_Instance( FT_Face face,
629+ FT_UInt instance_index );
630+
631+ /* */
632+
633+
634+FT_END_HEADER
635+
636+#endif /* FTMM_H_ */
637+
638+
639+/* END */
1@@ -0,0 +1,711 @@
2+/***************************************************************************/
3+/* */
4+/* ftmodapi.h */
5+/* */
6+/* FreeType modules public interface (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTMODAPI_H_
21+#define FTMODAPI_H_
22+
23+
24+#include <ft2build.h>
25+#include FT_FREETYPE_H
26+
27+#ifdef FREETYPE_H
28+#error "freetype.h of FreeType 1 has been loaded!"
29+#error "Please fix the directory search order for header files"
30+#error "so that freetype.h of FreeType 2 is found first."
31+#endif
32+
33+
34+FT_BEGIN_HEADER
35+
36+
37+ /*************************************************************************/
38+ /* */
39+ /* <Section> */
40+ /* module_management */
41+ /* */
42+ /* <Title> */
43+ /* Module Management */
44+ /* */
45+ /* <Abstract> */
46+ /* How to add, upgrade, remove, and control modules from FreeType. */
47+ /* */
48+ /* <Description> */
49+ /* The definitions below are used to manage modules within FreeType. */
50+ /* Modules can be added, upgraded, and removed at runtime. */
51+ /* Additionally, some module properties can be controlled also. */
52+ /* */
53+ /* Here is a list of possible values of the `module_name' field in */
54+ /* the @FT_Module_Class structure. */
55+ /* */
56+ /* { */
57+ /* autofitter */
58+ /* bdf */
59+ /* cff */
60+ /* gxvalid */
61+ /* otvalid */
62+ /* pcf */
63+ /* pfr */
64+ /* psaux */
65+ /* pshinter */
66+ /* psnames */
67+ /* raster1 */
68+ /* sfnt */
69+ /* smooth, smooth-lcd, smooth-lcdv */
70+ /* truetype */
71+ /* type1 */
72+ /* type42 */
73+ /* t1cid */
74+ /* winfonts */
75+ /* } */
76+ /* */
77+ /* Note that the FreeType Cache sub-system is not a FreeType module. */
78+ /* */
79+ /* <Order> */
80+ /* FT_Module */
81+ /* FT_Module_Constructor */
82+ /* FT_Module_Destructor */
83+ /* FT_Module_Requester */
84+ /* FT_Module_Class */
85+ /* */
86+ /* FT_Add_Module */
87+ /* FT_Get_Module */
88+ /* FT_Remove_Module */
89+ /* FT_Add_Default_Modules */
90+ /* */
91+ /* FT_Property_Set */
92+ /* FT_Property_Get */
93+ /* FT_Set_Default_Properties */
94+ /* */
95+ /* FT_New_Library */
96+ /* FT_Done_Library */
97+ /* FT_Reference_Library */
98+ /* */
99+ /* FT_Renderer */
100+ /* FT_Renderer_Class */
101+ /* */
102+ /* FT_Get_Renderer */
103+ /* FT_Set_Renderer */
104+ /* */
105+ /* FT_Set_Debug_Hook */
106+ /* */
107+ /*************************************************************************/
108+
109+
110+ /* module bit flags */
111+#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */
112+#define FT_MODULE_RENDERER 2 /* this module is a renderer */
113+#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */
114+#define FT_MODULE_STYLER 8 /* this module is a styler */
115+
116+#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */
117+ /* scalable fonts */
118+#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */
119+ /* support vector outlines */
120+#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */
121+ /* own hinter */
122+#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */
123+ /* produces LIGHT hints */
124+
125+
126+ /* deprecated values */
127+#define ft_module_font_driver FT_MODULE_FONT_DRIVER
128+#define ft_module_renderer FT_MODULE_RENDERER
129+#define ft_module_hinter FT_MODULE_HINTER
130+#define ft_module_styler FT_MODULE_STYLER
131+
132+#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE
133+#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
134+#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
135+#define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY
136+
137+
138+ typedef FT_Pointer FT_Module_Interface;
139+
140+
141+ /*************************************************************************/
142+ /* */
143+ /* <FuncType> */
144+ /* FT_Module_Constructor */
145+ /* */
146+ /* <Description> */
147+ /* A function used to initialize (not create) a new module object. */
148+ /* */
149+ /* <Input> */
150+ /* module :: The module to initialize. */
151+ /* */
152+ typedef FT_Error
153+ (*FT_Module_Constructor)( FT_Module module );
154+
155+
156+ /*************************************************************************/
157+ /* */
158+ /* <FuncType> */
159+ /* FT_Module_Destructor */
160+ /* */
161+ /* <Description> */
162+ /* A function used to finalize (not destroy) a given module object. */
163+ /* */
164+ /* <Input> */
165+ /* module :: The module to finalize. */
166+ /* */
167+ typedef void
168+ (*FT_Module_Destructor)( FT_Module module );
169+
170+
171+ /*************************************************************************/
172+ /* */
173+ /* <FuncType> */
174+ /* FT_Module_Requester */
175+ /* */
176+ /* <Description> */
177+ /* A function used to query a given module for a specific interface. */
178+ /* */
179+ /* <Input> */
180+ /* module :: The module to be searched. */
181+ /* */
182+ /* name :: The name of the interface in the module. */
183+ /* */
184+ typedef FT_Module_Interface
185+ (*FT_Module_Requester)( FT_Module module,
186+ const char* name );
187+
188+
189+ /*************************************************************************/
190+ /* */
191+ /* <Struct> */
192+ /* FT_Module_Class */
193+ /* */
194+ /* <Description> */
195+ /* The module class descriptor. */
196+ /* */
197+ /* <Fields> */
198+ /* module_flags :: Bit flags describing the module. */
199+ /* */
200+ /* module_size :: The size of one module object/instance in */
201+ /* bytes. */
202+ /* */
203+ /* module_name :: The name of the module. */
204+ /* */
205+ /* module_version :: The version, as a 16.16 fixed number */
206+ /* (major.minor). */
207+ /* */
208+ /* module_requires :: The version of FreeType this module requires, */
209+ /* as a 16.16 fixed number (major.minor). Starts */
210+ /* at version 2.0, i.e., 0x20000. */
211+ /* */
212+ /* module_init :: The initializing function. */
213+ /* */
214+ /* module_done :: The finalizing function. */
215+ /* */
216+ /* get_interface :: The interface requesting function. */
217+ /* */
218+ typedef struct FT_Module_Class_
219+ {
220+ FT_ULong module_flags;
221+ FT_Long module_size;
222+ const FT_String* module_name;
223+ FT_Fixed module_version;
224+ FT_Fixed module_requires;
225+
226+ const void* module_interface;
227+
228+ FT_Module_Constructor module_init;
229+ FT_Module_Destructor module_done;
230+ FT_Module_Requester get_interface;
231+
232+ } FT_Module_Class;
233+
234+
235+ /*************************************************************************/
236+ /* */
237+ /* <Function> */
238+ /* FT_Add_Module */
239+ /* */
240+ /* <Description> */
241+ /* Add a new module to a given library instance. */
242+ /* */
243+ /* <InOut> */
244+ /* library :: A handle to the library object. */
245+ /* */
246+ /* <Input> */
247+ /* clazz :: A pointer to class descriptor for the module. */
248+ /* */
249+ /* <Return> */
250+ /* FreeType error code. 0~means success. */
251+ /* */
252+ /* <Note> */
253+ /* An error will be returned if a module already exists by that name, */
254+ /* or if the module requires a version of FreeType that is too great. */
255+ /* */
256+ FT_EXPORT( FT_Error )
257+ FT_Add_Module( FT_Library library,
258+ const FT_Module_Class* clazz );
259+
260+
261+ /*************************************************************************/
262+ /* */
263+ /* <Function> */
264+ /* FT_Get_Module */
265+ /* */
266+ /* <Description> */
267+ /* Find a module by its name. */
268+ /* */
269+ /* <Input> */
270+ /* library :: A handle to the library object. */
271+ /* */
272+ /* module_name :: The module's name (as an ASCII string). */
273+ /* */
274+ /* <Return> */
275+ /* A module handle. 0~if none was found. */
276+ /* */
277+ /* <Note> */
278+ /* FreeType's internal modules aren't documented very well, and you */
279+ /* should look up the source code for details. */
280+ /* */
281+ FT_EXPORT( FT_Module )
282+ FT_Get_Module( FT_Library library,
283+ const char* module_name );
284+
285+
286+ /*************************************************************************/
287+ /* */
288+ /* <Function> */
289+ /* FT_Remove_Module */
290+ /* */
291+ /* <Description> */
292+ /* Remove a given module from a library instance. */
293+ /* */
294+ /* <InOut> */
295+ /* library :: A handle to a library object. */
296+ /* */
297+ /* <Input> */
298+ /* module :: A handle to a module object. */
299+ /* */
300+ /* <Return> */
301+ /* FreeType error code. 0~means success. */
302+ /* */
303+ /* <Note> */
304+ /* The module object is destroyed by the function in case of success. */
305+ /* */
306+ FT_EXPORT( FT_Error )
307+ FT_Remove_Module( FT_Library library,
308+ FT_Module module );
309+
310+
311+ /**********************************************************************
312+ *
313+ * @function:
314+ * FT_Property_Set
315+ *
316+ * @description:
317+ * Set a property for a given module.
318+ *
319+ * @input:
320+ * library ::
321+ * A handle to the library the module is part of.
322+ *
323+ * module_name ::
324+ * The module name.
325+ *
326+ * property_name ::
327+ * The property name. Properties are described in section
328+ * @properties.
329+ *
330+ * Note that only a few modules have properties.
331+ *
332+ * value ::
333+ * A generic pointer to a variable or structure that gives the new
334+ * value of the property. The exact definition of `value' is
335+ * dependent on the property; see section @properties.
336+ *
337+ * @return:
338+ * FreeType error code. 0~means success.
339+ *
340+ * @note:
341+ * If `module_name' isn't a valid module name, or `property_name'
342+ * doesn't specify a valid property, or if `value' doesn't represent a
343+ * valid value for the given property, an error is returned.
344+ *
345+ * The following example sets property `bar' (a simple integer) in
346+ * module `foo' to value~1.
347+ *
348+ * {
349+ * FT_UInt bar;
350+ *
351+ *
352+ * bar = 1;
353+ * FT_Property_Set( library, "foo", "bar", &bar );
354+ * }
355+ *
356+ * Note that the FreeType Cache sub-system doesn't recognize module
357+ * property changes. To avoid glyph lookup confusion within the cache
358+ * you should call @FTC_Manager_Reset to completely flush the cache if
359+ * a module property gets changed after @FTC_Manager_New has been
360+ * called.
361+ *
362+ * It is not possible to set properties of the FreeType Cache
363+ * sub-system itself with FT_Property_Set; use @FTC_Property_Set
364+ * instead.
365+ *
366+ * @since:
367+ * 2.4.11
368+ *
369+ */
370+ FT_EXPORT( FT_Error )
371+ FT_Property_Set( FT_Library library,
372+ const FT_String* module_name,
373+ const FT_String* property_name,
374+ const void* value );
375+
376+
377+ /**********************************************************************
378+ *
379+ * @function:
380+ * FT_Property_Get
381+ *
382+ * @description:
383+ * Get a module's property value.
384+ *
385+ * @input:
386+ * library ::
387+ * A handle to the library the module is part of.
388+ *
389+ * module_name ::
390+ * The module name.
391+ *
392+ * property_name ::
393+ * The property name. Properties are described in section
394+ * @properties.
395+ *
396+ * @inout:
397+ * value ::
398+ * A generic pointer to a variable or structure that gives the
399+ * value of the property. The exact definition of `value' is
400+ * dependent on the property; see section @properties.
401+ *
402+ * @return:
403+ * FreeType error code. 0~means success.
404+ *
405+ * @note:
406+ * If `module_name' isn't a valid module name, or `property_name'
407+ * doesn't specify a valid property, or if `value' doesn't represent a
408+ * valid value for the given property, an error is returned.
409+ *
410+ * The following example gets property `baz' (a range) in module `foo'.
411+ *
412+ * {
413+ * typedef range_
414+ * {
415+ * FT_Int32 min;
416+ * FT_Int32 max;
417+ *
418+ * } range;
419+ *
420+ * range baz;
421+ *
422+ *
423+ * FT_Property_Get( library, "foo", "baz", &baz );
424+ * }
425+ *
426+ * It is not possible to retrieve properties of the FreeType Cache
427+ * sub-system with FT_Property_Get; use @FTC_Property_Get instead.
428+ *
429+ * @since:
430+ * 2.4.11
431+ *
432+ */
433+ FT_EXPORT( FT_Error )
434+ FT_Property_Get( FT_Library library,
435+ const FT_String* module_name,
436+ const FT_String* property_name,
437+ void* value );
438+
439+
440+ /*************************************************************************/
441+ /* */
442+ /* <Function> */
443+ /* FT_Set_Default_Properties */
444+ /* */
445+ /* <Description> */
446+ /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */
447+ /* set, this function reads the `FREETYPE_PROPERTIES' environment */
448+ /* variable to control driver properties. See section @properties */
449+ /* for more. */
450+ /* */
451+ /* If the compilation option is not set, this function does nothing. */
452+ /* */
453+ /* `FREETYPE_PROPERTIES' has the following syntax form (broken here */
454+ /* into multiple lines for better readability). */
455+ /* */
456+ /* { */
457+ /* <optional whitespace> */
458+ /* <module-name1> ':' */
459+ /* <property-name1> '=' <property-value1> */
460+ /* <whitespace> */
461+ /* <module-name2> ':' */
462+ /* <property-name2> '=' <property-value2> */
463+ /* ... */
464+ /* } */
465+ /* */
466+ /* Example: */
467+ /* */
468+ /* { */
469+ /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */
470+ /* cff:no-stem-darkening=1 \ */
471+ /* autofitter:warping=1 */
472+ /* } */
473+ /* */
474+ /* <InOut> */
475+ /* library :: A handle to a new library object. */
476+ /* */
477+ /* <Since> */
478+ /* 2.8 */
479+ /* */
480+ FT_EXPORT( void )
481+ FT_Set_Default_Properties( FT_Library library );
482+
483+
484+ /*************************************************************************/
485+ /* */
486+ /* <Function> */
487+ /* FT_Reference_Library */
488+ /* */
489+ /* <Description> */
490+ /* A counter gets initialized to~1 at the time an @FT_Library */
491+ /* structure is created. This function increments the counter. */
492+ /* @FT_Done_Library then only destroys a library if the counter is~1, */
493+ /* otherwise it simply decrements the counter. */
494+ /* */
495+ /* This function helps in managing life-cycles of structures that */
496+ /* reference @FT_Library objects. */
497+ /* */
498+ /* <Input> */
499+ /* library :: A handle to a target library object. */
500+ /* */
501+ /* <Return> */
502+ /* FreeType error code. 0~means success. */
503+ /* */
504+ /* <Since> */
505+ /* 2.4.2 */
506+ /* */
507+ FT_EXPORT( FT_Error )
508+ FT_Reference_Library( FT_Library library );
509+
510+
511+ /*************************************************************************/
512+ /* */
513+ /* <Function> */
514+ /* FT_New_Library */
515+ /* */
516+ /* <Description> */
517+ /* This function is used to create a new FreeType library instance */
518+ /* from a given memory object. It is thus possible to use libraries */
519+ /* with distinct memory allocators within the same program. Note, */
520+ /* however, that the used @FT_Memory structure is expected to remain */
521+ /* valid for the life of the @FT_Library object. */
522+ /* */
523+ /* Normally, you would call this function (followed by a call to */
524+ /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, */
525+ /* and a call to @FT_Set_Default_Properties) instead of */
526+ /* @FT_Init_FreeType to initialize the FreeType library. */
527+ /* */
528+ /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */
529+ /* library instance. */
530+ /* */
531+ /* <Input> */
532+ /* memory :: A handle to the original memory object. */
533+ /* */
534+ /* <Output> */
535+ /* alibrary :: A pointer to handle of a new library object. */
536+ /* */
537+ /* <Return> */
538+ /* FreeType error code. 0~means success. */
539+ /* */
540+ /* <Note> */
541+ /* See the discussion of reference counters in the description of */
542+ /* @FT_Reference_Library. */
543+ /* */
544+ FT_EXPORT( FT_Error )
545+ FT_New_Library( FT_Memory memory,
546+ FT_Library *alibrary );
547+
548+
549+ /*************************************************************************/
550+ /* */
551+ /* <Function> */
552+ /* FT_Done_Library */
553+ /* */
554+ /* <Description> */
555+ /* Discard a given library object. This closes all drivers and */
556+ /* discards all resource objects. */
557+ /* */
558+ /* <Input> */
559+ /* library :: A handle to the target library. */
560+ /* */
561+ /* <Return> */
562+ /* FreeType error code. 0~means success. */
563+ /* */
564+ /* <Note> */
565+ /* See the discussion of reference counters in the description of */
566+ /* @FT_Reference_Library. */
567+ /* */
568+ FT_EXPORT( FT_Error )
569+ FT_Done_Library( FT_Library library );
570+
571+ /* */
572+
573+ typedef void
574+ (*FT_DebugHook_Func)( void* arg );
575+
576+
577+ /*************************************************************************/
578+ /* */
579+ /* <Function> */
580+ /* FT_Set_Debug_Hook */
581+ /* */
582+ /* <Description> */
583+ /* Set a debug hook function for debugging the interpreter of a font */
584+ /* format. */
585+ /* */
586+ /* <InOut> */
587+ /* library :: A handle to the library object. */
588+ /* */
589+ /* <Input> */
590+ /* hook_index :: The index of the debug hook. You should use the */
591+ /* values defined in `ftobjs.h', e.g., */
592+ /* `FT_DEBUG_HOOK_TRUETYPE'. */
593+ /* */
594+ /* debug_hook :: The function used to debug the interpreter. */
595+ /* */
596+ /* <Note> */
597+ /* Currently, four debug hook slots are available, but only two (for */
598+ /* the TrueType and the Type~1 interpreter) are defined. */
599+ /* */
600+ /* Since the internal headers of FreeType are no longer installed, */
601+ /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */
602+ /* This is a bug and will be fixed in a forthcoming release. */
603+ /* */
604+ FT_EXPORT( void )
605+ FT_Set_Debug_Hook( FT_Library library,
606+ FT_UInt hook_index,
607+ FT_DebugHook_Func debug_hook );
608+
609+
610+ /*************************************************************************/
611+ /* */
612+ /* <Function> */
613+ /* FT_Add_Default_Modules */
614+ /* */
615+ /* <Description> */
616+ /* Add the set of default drivers to a given library object. */
617+ /* This is only useful when you create a library object with */
618+ /* @FT_New_Library (usually to plug a custom memory manager). */
619+ /* */
620+ /* <InOut> */
621+ /* library :: A handle to a new library object. */
622+ /* */
623+ FT_EXPORT( void )
624+ FT_Add_Default_Modules( FT_Library library );
625+
626+
627+
628+ /**************************************************************************
629+ *
630+ * @section:
631+ * truetype_engine
632+ *
633+ * @title:
634+ * The TrueType Engine
635+ *
636+ * @abstract:
637+ * TrueType bytecode support.
638+ *
639+ * @description:
640+ * This section contains a function used to query the level of TrueType
641+ * bytecode support compiled in this version of the library.
642+ *
643+ */
644+
645+
646+ /**************************************************************************
647+ *
648+ * @enum:
649+ * FT_TrueTypeEngineType
650+ *
651+ * @description:
652+ * A list of values describing which kind of TrueType bytecode
653+ * engine is implemented in a given FT_Library instance. It is used
654+ * by the @FT_Get_TrueType_Engine_Type function.
655+ *
656+ * @values:
657+ * FT_TRUETYPE_ENGINE_TYPE_NONE ::
658+ * The library doesn't implement any kind of bytecode interpreter.
659+ *
660+ * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
661+ * Deprecated and removed.
662+ *
663+ * FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
664+ * The library implements a bytecode interpreter that covers
665+ * the full instruction set of the TrueType virtual machine (this
666+ * was governed by patents until May 2010, hence the name).
667+ *
668+ * @since:
669+ * 2.2
670+ *
671+ */
672+ typedef enum FT_TrueTypeEngineType_
673+ {
674+ FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
675+ FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
676+ FT_TRUETYPE_ENGINE_TYPE_PATENTED
677+
678+ } FT_TrueTypeEngineType;
679+
680+
681+ /**************************************************************************
682+ *
683+ * @func:
684+ * FT_Get_TrueType_Engine_Type
685+ *
686+ * @description:
687+ * Return an @FT_TrueTypeEngineType value to indicate which level of
688+ * the TrueType virtual machine a given library instance supports.
689+ *
690+ * @input:
691+ * library ::
692+ * A library instance.
693+ *
694+ * @return:
695+ * A value indicating which level is supported.
696+ *
697+ * @since:
698+ * 2.2
699+ *
700+ */
701+ FT_EXPORT( FT_TrueTypeEngineType )
702+ FT_Get_TrueType_Engine_Type( FT_Library library );
703+
704+ /* */
705+
706+
707+FT_END_HEADER
708+
709+#endif /* FTMODAPI_H_ */
710+
711+
712+/* END */
1@@ -0,0 +1,194 @@
2+/***************************************************************************/
3+/* */
4+/* ftmoderr.h */
5+/* */
6+/* FreeType module error offsets (specification). */
7+/* */
8+/* Copyright 2001-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+ /*************************************************************************/
21+ /* */
22+ /* This file is used to define the FreeType module error codes. */
23+ /* */
24+ /* If the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in `ftoption.h' is */
25+ /* set, the lower byte of an error value identifies the error code as */
26+ /* usual. In addition, the higher byte identifies the module. For */
27+ /* example, the error `FT_Err_Invalid_File_Format' has value 0x0003, the */
28+ /* error `TT_Err_Invalid_File_Format' has value 0x1303, the error */
29+ /* `T1_Err_Invalid_File_Format' has value 0x1403, etc. */
30+ /* */
31+ /* Note that `FT_Err_Ok', `TT_Err_Ok', etc. are always equal to zero, */
32+ /* including the high byte. */
33+ /* */
34+ /* If FT_CONFIG_OPTION_USE_MODULE_ERRORS isn't set, the higher byte of */
35+ /* an error value is set to zero. */
36+ /* */
37+ /* To hide the various `XXX_Err_' prefixes in the source code, FreeType */
38+ /* provides some macros in `fttypes.h'. */
39+ /* */
40+ /* FT_ERR( err ) */
41+ /* Add current error module prefix (as defined with the */
42+ /* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */
43+ /* the line */
44+ /* */
45+ /* error = FT_ERR( Invalid_Outline ); */
46+ /* */
47+ /* expands to */
48+ /* */
49+ /* error = BDF_Err_Invalid_Outline; */
50+ /* */
51+ /* For simplicity, you can always use `FT_Err_Ok' directly instead */
52+ /* of `FT_ERR( Ok )'. */
53+ /* */
54+ /* FT_ERR_EQ( errcode, err ) */
55+ /* FT_ERR_NEQ( errcode, err ) */
56+ /* Compare error code `errcode' with the error `err' for equality */
57+ /* and inequality, respectively. Example: */
58+ /* */
59+ /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */
60+ /* ... */
61+ /* */
62+ /* Using this macro you don't have to think about error prefixes. */
63+ /* Of course, if module errors are not active, the above example is */
64+ /* the same as */
65+ /* */
66+ /* if ( error == FT_Err_Invalid_Outline ) */
67+ /* ... */
68+ /* */
69+ /* FT_ERROR_BASE( errcode ) */
70+ /* FT_ERROR_MODULE( errcode ) */
71+ /* Get base error and module error code, respectively. */
72+ /* */
73+ /* */
74+ /* It can also be used to create a module error message table easily */
75+ /* with something like */
76+ /* */
77+ /* { */
78+ /* #undef FTMODERR_H_ */
79+ /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */
80+ /* #define FT_MODERR_START_LIST { */
81+ /* #define FT_MODERR_END_LIST { 0, 0 } }; */
82+ /* */
83+ /* const struct */
84+ /* { */
85+ /* int mod_err_offset; */
86+ /* const char* mod_err_msg */
87+ /* } ft_mod_errors[] = */
88+ /* */
89+ /* #include FT_MODULE_ERRORS_H */
90+ /* } */
91+ /* */
92+ /*************************************************************************/
93+
94+
95+#ifndef FTMODERR_H_
96+#define FTMODERR_H_
97+
98+
99+ /*******************************************************************/
100+ /*******************************************************************/
101+ /***** *****/
102+ /***** SETUP MACROS *****/
103+ /***** *****/
104+ /*******************************************************************/
105+ /*******************************************************************/
106+
107+
108+#undef FT_NEED_EXTERN_C
109+
110+#ifndef FT_MODERRDEF
111+
112+#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
113+#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v,
114+#else
115+#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0,
116+#endif
117+
118+#define FT_MODERR_START_LIST enum {
119+#define FT_MODERR_END_LIST FT_Mod_Err_Max };
120+
121+#ifdef __cplusplus
122+#define FT_NEED_EXTERN_C
123+ extern "C" {
124+#endif
125+
126+#endif /* !FT_MODERRDEF */
127+
128+
129+ /*******************************************************************/
130+ /*******************************************************************/
131+ /***** *****/
132+ /***** LIST MODULE ERROR BASES *****/
133+ /***** *****/
134+ /*******************************************************************/
135+ /*******************************************************************/
136+
137+
138+#ifdef FT_MODERR_START_LIST
139+ FT_MODERR_START_LIST
140+#endif
141+
142+
143+ FT_MODERRDEF( Base, 0x000, "base module" )
144+ FT_MODERRDEF( Autofit, 0x100, "autofitter module" )
145+ FT_MODERRDEF( BDF, 0x200, "BDF module" )
146+ FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" )
147+ FT_MODERRDEF( Cache, 0x400, "cache module" )
148+ FT_MODERRDEF( CFF, 0x500, "CFF module" )
149+ FT_MODERRDEF( CID, 0x600, "CID module" )
150+ FT_MODERRDEF( Gzip, 0x700, "Gzip module" )
151+ FT_MODERRDEF( LZW, 0x800, "LZW module" )
152+ FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" )
153+ FT_MODERRDEF( PCF, 0xA00, "PCF module" )
154+ FT_MODERRDEF( PFR, 0xB00, "PFR module" )
155+ FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" )
156+ FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" )
157+ FT_MODERRDEF( PSnames, 0xE00, "PS names module" )
158+ FT_MODERRDEF( Raster, 0xF00, "raster module" )
159+ FT_MODERRDEF( SFNT, 0x1000, "SFNT module" )
160+ FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" )
161+ FT_MODERRDEF( TrueType, 0x1200, "TrueType module" )
162+ FT_MODERRDEF( Type1, 0x1300, "Type 1 module" )
163+ FT_MODERRDEF( Type42, 0x1400, "Type 42 module" )
164+ FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" )
165+ FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" )
166+
167+
168+#ifdef FT_MODERR_END_LIST
169+ FT_MODERR_END_LIST
170+#endif
171+
172+
173+ /*******************************************************************/
174+ /*******************************************************************/
175+ /***** *****/
176+ /***** CLEANUP *****/
177+ /***** *****/
178+ /*******************************************************************/
179+ /*******************************************************************/
180+
181+
182+#ifdef FT_NEED_EXTERN_C
183+ }
184+#endif
185+
186+#undef FT_MODERR_START_LIST
187+#undef FT_MODERR_END_LIST
188+#undef FT_MODERRDEF
189+#undef FT_NEED_EXTERN_C
190+
191+
192+#endif /* FTMODERR_H_ */
193+
194+
195+/* END */
1@@ -0,0 +1,204 @@
2+/***************************************************************************/
3+/* */
4+/* ftotval.h */
5+/* */
6+/* FreeType API for validating OpenType tables (specification). */
7+/* */
8+/* Copyright 2004-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+/***************************************************************************/
21+/* */
22+/* */
23+/* Warning: This module might be moved to a different library in the */
24+/* future to avoid a tight dependency between FreeType and the */
25+/* OpenType specification. */
26+/* */
27+/* */
28+/***************************************************************************/
29+
30+
31+#ifndef FTOTVAL_H_
32+#define FTOTVAL_H_
33+
34+#include <ft2build.h>
35+#include FT_FREETYPE_H
36+
37+#ifdef FREETYPE_H
38+#error "freetype.h of FreeType 1 has been loaded!"
39+#error "Please fix the directory search order for header files"
40+#error "so that freetype.h of FreeType 2 is found first."
41+#endif
42+
43+
44+FT_BEGIN_HEADER
45+
46+
47+ /*************************************************************************/
48+ /* */
49+ /* <Section> */
50+ /* ot_validation */
51+ /* */
52+ /* <Title> */
53+ /* OpenType Validation */
54+ /* */
55+ /* <Abstract> */
56+ /* An API to validate OpenType tables. */
57+ /* */
58+ /* <Description> */
59+ /* This section contains the declaration of functions to validate */
60+ /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */
61+ /* */
62+ /* <Order> */
63+ /* FT_OpenType_Validate */
64+ /* FT_OpenType_Free */
65+ /* */
66+ /* FT_VALIDATE_OTXXX */
67+ /* */
68+ /*************************************************************************/
69+
70+
71+ /**********************************************************************
72+ *
73+ * @enum:
74+ * FT_VALIDATE_OTXXX
75+ *
76+ * @description:
77+ * A list of bit-field constants used with @FT_OpenType_Validate to
78+ * indicate which OpenType tables should be validated.
79+ *
80+ * @values:
81+ * FT_VALIDATE_BASE ::
82+ * Validate BASE table.
83+ *
84+ * FT_VALIDATE_GDEF ::
85+ * Validate GDEF table.
86+ *
87+ * FT_VALIDATE_GPOS ::
88+ * Validate GPOS table.
89+ *
90+ * FT_VALIDATE_GSUB ::
91+ * Validate GSUB table.
92+ *
93+ * FT_VALIDATE_JSTF ::
94+ * Validate JSTF table.
95+ *
96+ * FT_VALIDATE_MATH ::
97+ * Validate MATH table.
98+ *
99+ * FT_VALIDATE_OT ::
100+ * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH).
101+ *
102+ */
103+#define FT_VALIDATE_BASE 0x0100
104+#define FT_VALIDATE_GDEF 0x0200
105+#define FT_VALIDATE_GPOS 0x0400
106+#define FT_VALIDATE_GSUB 0x0800
107+#define FT_VALIDATE_JSTF 0x1000
108+#define FT_VALIDATE_MATH 0x2000
109+
110+#define FT_VALIDATE_OT ( FT_VALIDATE_BASE | \
111+ FT_VALIDATE_GDEF | \
112+ FT_VALIDATE_GPOS | \
113+ FT_VALIDATE_GSUB | \
114+ FT_VALIDATE_JSTF | \
115+ FT_VALIDATE_MATH )
116+
117+ /**********************************************************************
118+ *
119+ * @function:
120+ * FT_OpenType_Validate
121+ *
122+ * @description:
123+ * Validate various OpenType tables to assure that all offsets and
124+ * indices are valid. The idea is that a higher-level library that
125+ * actually does the text layout can access those tables without
126+ * error checking (which can be quite time consuming).
127+ *
128+ * @input:
129+ * face ::
130+ * A handle to the input face.
131+ *
132+ * validation_flags ::
133+ * A bit field that specifies the tables to be validated. See
134+ * @FT_VALIDATE_OTXXX for possible values.
135+ *
136+ * @output:
137+ * BASE_table ::
138+ * A pointer to the BASE table.
139+ *
140+ * GDEF_table ::
141+ * A pointer to the GDEF table.
142+ *
143+ * GPOS_table ::
144+ * A pointer to the GPOS table.
145+ *
146+ * GSUB_table ::
147+ * A pointer to the GSUB table.
148+ *
149+ * JSTF_table ::
150+ * A pointer to the JSTF table.
151+ *
152+ * @return:
153+ * FreeType error code. 0~means success.
154+ *
155+ * @note:
156+ * This function only works with OpenType fonts, returning an error
157+ * otherwise.
158+ *
159+ * After use, the application should deallocate the five tables with
160+ * @FT_OpenType_Free. A NULL value indicates that the table either
161+ * doesn't exist in the font, or the application hasn't asked for
162+ * validation.
163+ */
164+ FT_EXPORT( FT_Error )
165+ FT_OpenType_Validate( FT_Face face,
166+ FT_UInt validation_flags,
167+ FT_Bytes *BASE_table,
168+ FT_Bytes *GDEF_table,
169+ FT_Bytes *GPOS_table,
170+ FT_Bytes *GSUB_table,
171+ FT_Bytes *JSTF_table );
172+
173+ /**********************************************************************
174+ *
175+ * @function:
176+ * FT_OpenType_Free
177+ *
178+ * @description:
179+ * Free the buffer allocated by OpenType validator.
180+ *
181+ * @input:
182+ * face ::
183+ * A handle to the input face.
184+ *
185+ * table ::
186+ * The pointer to the buffer that is allocated by
187+ * @FT_OpenType_Validate.
188+ *
189+ * @note:
190+ * This function must be used to free the buffer allocated by
191+ * @FT_OpenType_Validate only.
192+ */
193+ FT_EXPORT( void )
194+ FT_OpenType_Free( FT_Face face,
195+ FT_Bytes table );
196+
197+ /* */
198+
199+
200+FT_END_HEADER
201+
202+#endif /* FTOTVAL_H_ */
203+
204+
205+/* END */
1@@ -0,0 +1,582 @@
2+/***************************************************************************/
3+/* */
4+/* ftoutln.h */
5+/* */
6+/* Support for the FT_Outline type used to store glyph shapes of */
7+/* most scalable font formats (specification). */
8+/* */
9+/* Copyright 1996-2018 by */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+
21+#ifndef FTOUTLN_H_
22+#define FTOUTLN_H_
23+
24+
25+#include <ft2build.h>
26+#include FT_FREETYPE_H
27+
28+#ifdef FREETYPE_H
29+#error "freetype.h of FreeType 1 has been loaded!"
30+#error "Please fix the directory search order for header files"
31+#error "so that freetype.h of FreeType 2 is found first."
32+#endif
33+
34+
35+FT_BEGIN_HEADER
36+
37+
38+ /*************************************************************************/
39+ /* */
40+ /* <Section> */
41+ /* outline_processing */
42+ /* */
43+ /* <Title> */
44+ /* Outline Processing */
45+ /* */
46+ /* <Abstract> */
47+ /* Functions to create, transform, and render vectorial glyph images. */
48+ /* */
49+ /* <Description> */
50+ /* This section contains routines used to create and destroy scalable */
51+ /* glyph images known as `outlines'. These can also be measured, */
52+ /* transformed, and converted into bitmaps and pixmaps. */
53+ /* */
54+ /* <Order> */
55+ /* FT_Outline */
56+ /* FT_Outline_New */
57+ /* FT_Outline_Done */
58+ /* FT_Outline_Copy */
59+ /* FT_Outline_Translate */
60+ /* FT_Outline_Transform */
61+ /* FT_Outline_Embolden */
62+ /* FT_Outline_EmboldenXY */
63+ /* FT_Outline_Reverse */
64+ /* FT_Outline_Check */
65+ /* */
66+ /* FT_Outline_Get_CBox */
67+ /* FT_Outline_Get_BBox */
68+ /* */
69+ /* FT_Outline_Get_Bitmap */
70+ /* FT_Outline_Render */
71+ /* FT_Outline_Decompose */
72+ /* FT_Outline_Funcs */
73+ /* FT_Outline_MoveToFunc */
74+ /* FT_Outline_LineToFunc */
75+ /* FT_Outline_ConicToFunc */
76+ /* FT_Outline_CubicToFunc */
77+ /* */
78+ /* FT_Orientation */
79+ /* FT_Outline_Get_Orientation */
80+ /* */
81+ /* FT_OUTLINE_XXX */
82+ /* */
83+ /*************************************************************************/
84+
85+
86+ /*************************************************************************/
87+ /* */
88+ /* <Function> */
89+ /* FT_Outline_Decompose */
90+ /* */
91+ /* <Description> */
92+ /* Walk over an outline's structure to decompose it into individual */
93+ /* segments and Bezier arcs. This function also emits `move to' */
94+ /* operations to indicate the start of new contours in the outline. */
95+ /* */
96+ /* <Input> */
97+ /* outline :: A pointer to the source target. */
98+ /* */
99+ /* func_interface :: A table of `emitters', i.e., function pointers */
100+ /* called during decomposition to indicate path */
101+ /* operations. */
102+ /* */
103+ /* <InOut> */
104+ /* user :: A typeless pointer that is passed to each */
105+ /* emitter during the decomposition. It can be */
106+ /* used to store the state during the */
107+ /* decomposition. */
108+ /* */
109+ /* <Return> */
110+ /* FreeType error code. 0~means success. */
111+ /* */
112+ /* <Note> */
113+ /* A contour that contains a single point only is represented by a */
114+ /* `move to' operation followed by `line to' to the same point. In */
115+ /* most cases, it is best to filter this out before using the */
116+ /* outline for stroking purposes (otherwise it would result in a */
117+ /* visible dot when round caps are used). */
118+ /* */
119+ /* Similarly, the function returns success for an empty outline also */
120+ /* (doing nothing, this is, not calling any emitter); if necessary, */
121+ /* you should filter this out, too. */
122+ /* */
123+ FT_EXPORT( FT_Error )
124+ FT_Outline_Decompose( FT_Outline* outline,
125+ const FT_Outline_Funcs* func_interface,
126+ void* user );
127+
128+
129+ /*************************************************************************/
130+ /* */
131+ /* <Function> */
132+ /* FT_Outline_New */
133+ /* */
134+ /* <Description> */
135+ /* Create a new outline of a given size. */
136+ /* */
137+ /* <Input> */
138+ /* library :: A handle to the library object from where the */
139+ /* outline is allocated. Note however that the new */
140+ /* outline will *not* necessarily be *freed*, when */
141+ /* destroying the library, by @FT_Done_FreeType. */
142+ /* */
143+ /* numPoints :: The maximum number of points within the outline. */
144+ /* Must be smaller than or equal to 0xFFFF (65535). */
145+ /* */
146+ /* numContours :: The maximum number of contours within the outline. */
147+ /* This value must be in the range 0 to `numPoints'. */
148+ /* */
149+ /* <Output> */
150+ /* anoutline :: A handle to the new outline. */
151+ /* */
152+ /* <Return> */
153+ /* FreeType error code. 0~means success. */
154+ /* */
155+ /* <Note> */
156+ /* The reason why this function takes a `library' parameter is simply */
157+ /* to use the library's memory allocator. */
158+ /* */
159+ FT_EXPORT( FT_Error )
160+ FT_Outline_New( FT_Library library,
161+ FT_UInt numPoints,
162+ FT_Int numContours,
163+ FT_Outline *anoutline );
164+
165+
166+ FT_EXPORT( FT_Error )
167+ FT_Outline_New_Internal( FT_Memory memory,
168+ FT_UInt numPoints,
169+ FT_Int numContours,
170+ FT_Outline *anoutline );
171+
172+
173+ /*************************************************************************/
174+ /* */
175+ /* <Function> */
176+ /* FT_Outline_Done */
177+ /* */
178+ /* <Description> */
179+ /* Destroy an outline created with @FT_Outline_New. */
180+ /* */
181+ /* <Input> */
182+ /* library :: A handle of the library object used to allocate the */
183+ /* outline. */
184+ /* */
185+ /* outline :: A pointer to the outline object to be discarded. */
186+ /* */
187+ /* <Return> */
188+ /* FreeType error code. 0~means success. */
189+ /* */
190+ /* <Note> */
191+ /* If the outline's `owner' field is not set, only the outline */
192+ /* descriptor will be released. */
193+ /* */
194+ FT_EXPORT( FT_Error )
195+ FT_Outline_Done( FT_Library library,
196+ FT_Outline* outline );
197+
198+
199+ FT_EXPORT( FT_Error )
200+ FT_Outline_Done_Internal( FT_Memory memory,
201+ FT_Outline* outline );
202+
203+
204+ /*************************************************************************/
205+ /* */
206+ /* <Function> */
207+ /* FT_Outline_Check */
208+ /* */
209+ /* <Description> */
210+ /* Check the contents of an outline descriptor. */
211+ /* */
212+ /* <Input> */
213+ /* outline :: A handle to a source outline. */
214+ /* */
215+ /* <Return> */
216+ /* FreeType error code. 0~means success. */
217+ /* */
218+ /* <Note> */
219+ /* An empty outline, or an outline with a single point only is also */
220+ /* valid. */
221+ /* */
222+ FT_EXPORT( FT_Error )
223+ FT_Outline_Check( FT_Outline* outline );
224+
225+
226+ /*************************************************************************/
227+ /* */
228+ /* <Function> */
229+ /* FT_Outline_Get_CBox */
230+ /* */
231+ /* <Description> */
232+ /* Return an outline's `control box'. The control box encloses all */
233+ /* the outline's points, including Bezier control points. Though it */
234+ /* coincides with the exact bounding box for most glyphs, it can be */
235+ /* slightly larger in some situations (like when rotating an outline */
236+ /* that contains Bezier outside arcs). */
237+ /* */
238+ /* Computing the control box is very fast, while getting the bounding */
239+ /* box can take much more time as it needs to walk over all segments */
240+ /* and arcs in the outline. To get the latter, you can use the */
241+ /* `ftbbox' component, which is dedicated to this single task. */
242+ /* */
243+ /* <Input> */
244+ /* outline :: A pointer to the source outline descriptor. */
245+ /* */
246+ /* <Output> */
247+ /* acbox :: The outline's control box. */
248+ /* */
249+ /* <Note> */
250+ /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
251+ /* */
252+ FT_EXPORT( void )
253+ FT_Outline_Get_CBox( const FT_Outline* outline,
254+ FT_BBox *acbox );
255+
256+
257+ /*************************************************************************/
258+ /* */
259+ /* <Function> */
260+ /* FT_Outline_Translate */
261+ /* */
262+ /* <Description> */
263+ /* Apply a simple translation to the points of an outline. */
264+ /* */
265+ /* <InOut> */
266+ /* outline :: A pointer to the target outline descriptor. */
267+ /* */
268+ /* <Input> */
269+ /* xOffset :: The horizontal offset. */
270+ /* */
271+ /* yOffset :: The vertical offset. */
272+ /* */
273+ FT_EXPORT( void )
274+ FT_Outline_Translate( const FT_Outline* outline,
275+ FT_Pos xOffset,
276+ FT_Pos yOffset );
277+
278+
279+ /*************************************************************************/
280+ /* */
281+ /* <Function> */
282+ /* FT_Outline_Copy */
283+ /* */
284+ /* <Description> */
285+ /* Copy an outline into another one. Both objects must have the */
286+ /* same sizes (number of points & number of contours) when this */
287+ /* function is called. */
288+ /* */
289+ /* <Input> */
290+ /* source :: A handle to the source outline. */
291+ /* */
292+ /* <Output> */
293+ /* target :: A handle to the target outline. */
294+ /* */
295+ /* <Return> */
296+ /* FreeType error code. 0~means success. */
297+ /* */
298+ FT_EXPORT( FT_Error )
299+ FT_Outline_Copy( const FT_Outline* source,
300+ FT_Outline *target );
301+
302+
303+ /*************************************************************************/
304+ /* */
305+ /* <Function> */
306+ /* FT_Outline_Transform */
307+ /* */
308+ /* <Description> */
309+ /* Apply a simple 2x2 matrix to all of an outline's points. Useful */
310+ /* for applying rotations, slanting, flipping, etc. */
311+ /* */
312+ /* <InOut> */
313+ /* outline :: A pointer to the target outline descriptor. */
314+ /* */
315+ /* <Input> */
316+ /* matrix :: A pointer to the transformation matrix. */
317+ /* */
318+ /* <Note> */
319+ /* You can use @FT_Outline_Translate if you need to translate the */
320+ /* outline's points. */
321+ /* */
322+ FT_EXPORT( void )
323+ FT_Outline_Transform( const FT_Outline* outline,
324+ const FT_Matrix* matrix );
325+
326+
327+ /*************************************************************************/
328+ /* */
329+ /* <Function> */
330+ /* FT_Outline_Embolden */
331+ /* */
332+ /* <Description> */
333+ /* Embolden an outline. The new outline will be at most 4~times */
334+ /* `strength' pixels wider and higher. You may think of the left and */
335+ /* bottom borders as unchanged. */
336+ /* */
337+ /* Negative `strength' values to reduce the outline thickness are */
338+ /* possible also. */
339+ /* */
340+ /* <InOut> */
341+ /* outline :: A handle to the target outline. */
342+ /* */
343+ /* <Input> */
344+ /* strength :: How strong the glyph is emboldened. Expressed in */
345+ /* 26.6 pixel format. */
346+ /* */
347+ /* <Return> */
348+ /* FreeType error code. 0~means success. */
349+ /* */
350+ /* <Note> */
351+ /* The used algorithm to increase or decrease the thickness of the */
352+ /* glyph doesn't change the number of points; this means that certain */
353+ /* situations like acute angles or intersections are sometimes */
354+ /* handled incorrectly. */
355+ /* */
356+ /* If you need `better' metrics values you should call */
357+ /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */
358+ /* */
359+ /* Example call: */
360+ /* */
361+ /* { */
362+ /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */
363+ /* if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) */
364+ /* FT_Outline_Embolden( &face->glyph->outline, strength ); */
365+ /* } */
366+ /* */
367+ /* To get meaningful results, font scaling values must be set with */
368+ /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */
369+ /* */
370+ FT_EXPORT( FT_Error )
371+ FT_Outline_Embolden( FT_Outline* outline,
372+ FT_Pos strength );
373+
374+
375+ /*************************************************************************/
376+ /* */
377+ /* <Function> */
378+ /* FT_Outline_EmboldenXY */
379+ /* */
380+ /* <Description> */
381+ /* Embolden an outline. The new outline will be `xstrength' pixels */
382+ /* wider and `ystrength' pixels higher. Otherwise, it is similar to */
383+ /* @FT_Outline_Embolden, which uses the same strength in both */
384+ /* directions. */
385+ /* */
386+ /* <Since> */
387+ /* 2.4.10 */
388+ /* */
389+ FT_EXPORT( FT_Error )
390+ FT_Outline_EmboldenXY( FT_Outline* outline,
391+ FT_Pos xstrength,
392+ FT_Pos ystrength );
393+
394+
395+ /*************************************************************************/
396+ /* */
397+ /* <Function> */
398+ /* FT_Outline_Reverse */
399+ /* */
400+ /* <Description> */
401+ /* Reverse the drawing direction of an outline. This is used to */
402+ /* ensure consistent fill conventions for mirrored glyphs. */
403+ /* */
404+ /* <InOut> */
405+ /* outline :: A pointer to the target outline descriptor. */
406+ /* */
407+ /* <Note> */
408+ /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */
409+ /* the outline's `flags' field. */
410+ /* */
411+ /* It shouldn't be used by a normal client application, unless it */
412+ /* knows what it is doing. */
413+ /* */
414+ FT_EXPORT( void )
415+ FT_Outline_Reverse( FT_Outline* outline );
416+
417+
418+ /*************************************************************************/
419+ /* */
420+ /* <Function> */
421+ /* FT_Outline_Get_Bitmap */
422+ /* */
423+ /* <Description> */
424+ /* Render an outline within a bitmap. The outline's image is simply */
425+ /* OR-ed to the target bitmap. */
426+ /* */
427+ /* <Input> */
428+ /* library :: A handle to a FreeType library object. */
429+ /* */
430+ /* outline :: A pointer to the source outline descriptor. */
431+ /* */
432+ /* <InOut> */
433+ /* abitmap :: A pointer to the target bitmap descriptor. */
434+ /* */
435+ /* <Return> */
436+ /* FreeType error code. 0~means success. */
437+ /* */
438+ /* <Note> */
439+ /* This function does NOT CREATE the bitmap, it only renders an */
440+ /* outline image within the one you pass to it! Consequently, the */
441+ /* various fields in `abitmap' should be set accordingly. */
442+ /* */
443+ /* It will use the raster corresponding to the default glyph format. */
444+ /* */
445+ /* The value of the `num_grays' field in `abitmap' is ignored. If */
446+ /* you select the gray-level rasterizer, and you want less than 256 */
447+ /* gray levels, you have to use @FT_Outline_Render directly. */
448+ /* */
449+ FT_EXPORT( FT_Error )
450+ FT_Outline_Get_Bitmap( FT_Library library,
451+ FT_Outline* outline,
452+ const FT_Bitmap *abitmap );
453+
454+
455+ /*************************************************************************/
456+ /* */
457+ /* <Function> */
458+ /* FT_Outline_Render */
459+ /* */
460+ /* <Description> */
461+ /* Render an outline within a bitmap using the current scan-convert. */
462+ /* This function uses an @FT_Raster_Params structure as an argument, */
463+ /* allowing advanced features like direct composition, translucency, */
464+ /* etc. */
465+ /* */
466+ /* <Input> */
467+ /* library :: A handle to a FreeType library object. */
468+ /* */
469+ /* outline :: A pointer to the source outline descriptor. */
470+ /* */
471+ /* <InOut> */
472+ /* params :: A pointer to an @FT_Raster_Params structure used to */
473+ /* describe the rendering operation. */
474+ /* */
475+ /* <Return> */
476+ /* FreeType error code. 0~means success. */
477+ /* */
478+ /* <Note> */
479+ /* You should know what you are doing and how @FT_Raster_Params works */
480+ /* to use this function. */
481+ /* */
482+ /* The field `params.source' will be set to `outline' before the scan */
483+ /* converter is called, which means that the value you give to it is */
484+ /* actually ignored. */
485+ /* */
486+ /* The gray-level rasterizer always uses 256 gray levels. If you */
487+ /* want less gray levels, you have to provide your own span callback. */
488+ /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */
489+ /* @FT_Raster_Params structure for more details. */
490+ /* */
491+ FT_EXPORT( FT_Error )
492+ FT_Outline_Render( FT_Library library,
493+ FT_Outline* outline,
494+ FT_Raster_Params* params );
495+
496+
497+ /**************************************************************************
498+ *
499+ * @enum:
500+ * FT_Orientation
501+ *
502+ * @description:
503+ * A list of values used to describe an outline's contour orientation.
504+ *
505+ * The TrueType and PostScript specifications use different conventions
506+ * to determine whether outline contours should be filled or unfilled.
507+ *
508+ * @values:
509+ * FT_ORIENTATION_TRUETYPE ::
510+ * According to the TrueType specification, clockwise contours must
511+ * be filled, and counter-clockwise ones must be unfilled.
512+ *
513+ * FT_ORIENTATION_POSTSCRIPT ::
514+ * According to the PostScript specification, counter-clockwise contours
515+ * must be filled, and clockwise ones must be unfilled.
516+ *
517+ * FT_ORIENTATION_FILL_RIGHT ::
518+ * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
519+ * remember that in TrueType, everything that is to the right of
520+ * the drawing direction of a contour must be filled.
521+ *
522+ * FT_ORIENTATION_FILL_LEFT ::
523+ * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
524+ * remember that in PostScript, everything that is to the left of
525+ * the drawing direction of a contour must be filled.
526+ *
527+ * FT_ORIENTATION_NONE ::
528+ * The orientation cannot be determined. That is, different parts of
529+ * the glyph have different orientation.
530+ *
531+ */
532+ typedef enum FT_Orientation_
533+ {
534+ FT_ORIENTATION_TRUETYPE = 0,
535+ FT_ORIENTATION_POSTSCRIPT = 1,
536+ FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
537+ FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT,
538+ FT_ORIENTATION_NONE
539+
540+ } FT_Orientation;
541+
542+
543+ /**************************************************************************
544+ *
545+ * @function:
546+ * FT_Outline_Get_Orientation
547+ *
548+ * @description:
549+ * This function analyzes a glyph outline and tries to compute its
550+ * fill orientation (see @FT_Orientation). This is done by integrating
551+ * the total area covered by the outline. The positive integral
552+ * corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT
553+ * is returned. The negative integral corresponds to the counter-clockwise
554+ * orientation and @FT_ORIENTATION_TRUETYPE is returned.
555+ *
556+ * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
557+ * outlines.
558+ *
559+ * @input:
560+ * outline ::
561+ * A handle to the source outline.
562+ *
563+ * @return:
564+ * The orientation.
565+ *
566+ */
567+ FT_EXPORT( FT_Orientation )
568+ FT_Outline_Get_Orientation( FT_Outline* outline );
569+
570+ /* */
571+
572+
573+FT_END_HEADER
574+
575+#endif /* FTOUTLN_H_ */
576+
577+
578+/* END */
579+
580+
581+/* Local Variables: */
582+/* coding: utf-8 */
583+/* End: */
1@@ -0,0 +1,205 @@
2+/***************************************************************************/
3+/* */
4+/* ftparams.h */
5+/* */
6+/* FreeType API for possible FT_Parameter tags (specification only). */
7+/* */
8+/* Copyright 2017-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTPARAMS_H_
21+#define FTPARAMS_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+
36+ /**************************************************************************
37+ *
38+ * @section:
39+ * parameter_tags
40+ *
41+ * @title:
42+ * Parameter Tags
43+ *
44+ * @abstract:
45+ * Macros for driver property and font loading parameter tags.
46+ *
47+ * @description:
48+ * This section contains macros for the @FT_Parameter structure that are
49+ * used with various functions to activate some special functionality or
50+ * different behaviour of various components of FreeType.
51+ *
52+ */
53+
54+
55+ /***************************************************************************
56+ *
57+ * @constant:
58+ * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY
59+ *
60+ * @description:
61+ * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic
62+ * family names in the `name' table (introduced in OpenType version
63+ * 1.4). Use this for backward compatibility with legacy systems that
64+ * have a four-faces-per-family restriction.
65+ *
66+ * @since:
67+ * 2.8
68+ *
69+ */
70+#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY \
71+ FT_MAKE_TAG( 'i', 'g', 'p', 'f' )
72+
73+
74+ /* this constant is deprecated */
75+#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY \
76+ FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY
77+
78+
79+ /***************************************************************************
80+ *
81+ * @constant:
82+ * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY
83+ *
84+ * @description:
85+ * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic
86+ * subfamily names in the `name' table (introduced in OpenType version
87+ * 1.4). Use this for backward compatibility with legacy systems that
88+ * have a four-faces-per-family restriction.
89+ *
90+ * @since:
91+ * 2.8
92+ *
93+ */
94+#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY \
95+ FT_MAKE_TAG( 'i', 'g', 'p', 's' )
96+
97+
98+ /* this constant is deprecated */
99+#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY \
100+ FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY
101+
102+
103+ /***************************************************************************
104+ *
105+ * @constant:
106+ * FT_PARAM_TAG_INCREMENTAL
107+ *
108+ * @description:
109+ * An @FT_Parameter tag to be used with @FT_Open_Face to indicate
110+ * incremental glyph loading.
111+ *
112+ */
113+#define FT_PARAM_TAG_INCREMENTAL \
114+ FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
115+
116+
117+ /**************************************************************************
118+ *
119+ * @constant:
120+ * FT_PARAM_TAG_LCD_FILTER_WEIGHTS
121+ *
122+ * @description:
123+ * An @FT_Parameter tag to be used with @FT_Face_Properties. The
124+ * corresponding argument specifies the five LCD filter weights for a
125+ * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding
126+ * the global default values or the values set up with
127+ * @FT_Library_SetLcdFilterWeights.
128+ *
129+ * @since:
130+ * 2.8
131+ *
132+ */
133+#define FT_PARAM_TAG_LCD_FILTER_WEIGHTS \
134+ FT_MAKE_TAG( 'l', 'c', 'd', 'f' )
135+
136+
137+ /**************************************************************************
138+ *
139+ * @constant:
140+ * FT_PARAM_TAG_RANDOM_SEED
141+ *
142+ * @description:
143+ * An @FT_Parameter tag to be used with @FT_Face_Properties. The
144+ * corresponding 32bit signed integer argument overrides the font
145+ * driver's random seed value with a face-specific one; see
146+ * @random-seed.
147+ *
148+ * @since:
149+ * 2.8
150+ *
151+ */
152+#define FT_PARAM_TAG_RANDOM_SEED \
153+ FT_MAKE_TAG( 's', 'e', 'e', 'd' )
154+
155+
156+ /**************************************************************************
157+ *
158+ * @constant:
159+ * FT_PARAM_TAG_STEM_DARKENING
160+ *
161+ * @description:
162+ * An @FT_Parameter tag to be used with @FT_Face_Properties. The
163+ * corresponding Boolean argument specifies whether to apply stem
164+ * darkening, overriding the global default values or the values set up
165+ * with @FT_Property_Set (see @no-stem-darkening).
166+ *
167+ * This is a passive setting that only takes effect if the font driver
168+ * or autohinter honors it, which the CFF, Type~1, and CID drivers
169+ * always do, but the autohinter only in `light' hinting mode (as of
170+ * version 2.9).
171+ *
172+ * @since:
173+ * 2.8
174+ *
175+ */
176+#define FT_PARAM_TAG_STEM_DARKENING \
177+ FT_MAKE_TAG( 'd', 'a', 'r', 'k' )
178+
179+
180+ /***************************************************************************
181+ *
182+ * @constant:
183+ * FT_PARAM_TAG_UNPATENTED_HINTING
184+ *
185+ * @description:
186+ * Deprecated, no effect.
187+ *
188+ * Previously: A constant used as the tag of an @FT_Parameter structure to
189+ * indicate that unpatented methods only should be used by the TrueType
190+ * bytecode interpreter for a typeface opened by @FT_Open_Face.
191+ *
192+ */
193+#define FT_PARAM_TAG_UNPATENTED_HINTING \
194+ FT_MAKE_TAG( 'u', 'n', 'p', 'a' )
195+
196+
197+ /* */
198+
199+
200+FT_END_HEADER
201+
202+
203+#endif /* FTPARAMS_H_ */
204+
205+
206+/* END */
+172,
-0
1@@ -0,0 +1,172 @@
2+/***************************************************************************/
3+/* */
4+/* ftpfr.h */
5+/* */
6+/* FreeType API for accessing PFR-specific data (specification only). */
7+/* */
8+/* Copyright 2002-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTPFR_H_
21+#define FTPFR_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+
36+ /*************************************************************************/
37+ /* */
38+ /* <Section> */
39+ /* pfr_fonts */
40+ /* */
41+ /* <Title> */
42+ /* PFR Fonts */
43+ /* */
44+ /* <Abstract> */
45+ /* PFR/TrueDoc specific API. */
46+ /* */
47+ /* <Description> */
48+ /* This section contains the declaration of PFR-specific functions. */
49+ /* */
50+ /*************************************************************************/
51+
52+
53+ /**********************************************************************
54+ *
55+ * @function:
56+ * FT_Get_PFR_Metrics
57+ *
58+ * @description:
59+ * Return the outline and metrics resolutions of a given PFR face.
60+ *
61+ * @input:
62+ * face :: Handle to the input face. It can be a non-PFR face.
63+ *
64+ * @output:
65+ * aoutline_resolution ::
66+ * Outline resolution. This is equivalent to `face->units_per_EM'
67+ * for non-PFR fonts. Optional (parameter can be NULL).
68+ *
69+ * ametrics_resolution ::
70+ * Metrics resolution. This is equivalent to `outline_resolution'
71+ * for non-PFR fonts. Optional (parameter can be NULL).
72+ *
73+ * ametrics_x_scale ::
74+ * A 16.16 fixed-point number used to scale distance expressed
75+ * in metrics units to device subpixels. This is equivalent to
76+ * `face->size->x_scale', but for metrics only. Optional (parameter
77+ * can be NULL).
78+ *
79+ * ametrics_y_scale ::
80+ * Same as `ametrics_x_scale' but for the vertical direction.
81+ * optional (parameter can be NULL).
82+ *
83+ * @return:
84+ * FreeType error code. 0~means success.
85+ *
86+ * @note:
87+ * If the input face is not a PFR, this function will return an error.
88+ * However, in all cases, it will return valid values.
89+ */
90+ FT_EXPORT( FT_Error )
91+ FT_Get_PFR_Metrics( FT_Face face,
92+ FT_UInt *aoutline_resolution,
93+ FT_UInt *ametrics_resolution,
94+ FT_Fixed *ametrics_x_scale,
95+ FT_Fixed *ametrics_y_scale );
96+
97+
98+ /**********************************************************************
99+ *
100+ * @function:
101+ * FT_Get_PFR_Kerning
102+ *
103+ * @description:
104+ * Return the kerning pair corresponding to two glyphs in a PFR face.
105+ * The distance is expressed in metrics units, unlike the result of
106+ * @FT_Get_Kerning.
107+ *
108+ * @input:
109+ * face :: A handle to the input face.
110+ *
111+ * left :: Index of the left glyph.
112+ *
113+ * right :: Index of the right glyph.
114+ *
115+ * @output:
116+ * avector :: A kerning vector.
117+ *
118+ * @return:
119+ * FreeType error code. 0~means success.
120+ *
121+ * @note:
122+ * This function always return distances in original PFR metrics
123+ * units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED
124+ * mode, which always returns distances converted to outline units.
125+ *
126+ * You can use the value of the `x_scale' and `y_scale' parameters
127+ * returned by @FT_Get_PFR_Metrics to scale these to device subpixels.
128+ */
129+ FT_EXPORT( FT_Error )
130+ FT_Get_PFR_Kerning( FT_Face face,
131+ FT_UInt left,
132+ FT_UInt right,
133+ FT_Vector *avector );
134+
135+
136+ /**********************************************************************
137+ *
138+ * @function:
139+ * FT_Get_PFR_Advance
140+ *
141+ * @description:
142+ * Return a given glyph advance, expressed in original metrics units,
143+ * from a PFR font.
144+ *
145+ * @input:
146+ * face :: A handle to the input face.
147+ *
148+ * gindex :: The glyph index.
149+ *
150+ * @output:
151+ * aadvance :: The glyph advance in metrics units.
152+ *
153+ * @return:
154+ * FreeType error code. 0~means success.
155+ *
156+ * @note:
157+ * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics
158+ * to convert the advance to device subpixels (i.e., 1/64th of pixels).
159+ */
160+ FT_EXPORT( FT_Error )
161+ FT_Get_PFR_Advance( FT_Face face,
162+ FT_UInt gindex,
163+ FT_Pos *aadvance );
164+
165+ /* */
166+
167+
168+FT_END_HEADER
169+
170+#endif /* FTPFR_H_ */
171+
172+
173+/* END */
1@@ -0,0 +1,233 @@
2+/***************************************************************************/
3+/* */
4+/* ftrender.h */
5+/* */
6+/* FreeType renderer modules public interface (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTRENDER_H_
21+#define FTRENDER_H_
22+
23+
24+#include <ft2build.h>
25+#include FT_MODULE_H
26+#include FT_GLYPH_H
27+
28+
29+FT_BEGIN_HEADER
30+
31+
32+ /*************************************************************************/
33+ /* */
34+ /* <Section> */
35+ /* module_management */
36+ /* */
37+ /*************************************************************************/
38+
39+
40+ /* create a new glyph object */
41+ typedef FT_Error
42+ (*FT_Glyph_InitFunc)( FT_Glyph glyph,
43+ FT_GlyphSlot slot );
44+
45+ /* destroys a given glyph object */
46+ typedef void
47+ (*FT_Glyph_DoneFunc)( FT_Glyph glyph );
48+
49+ typedef void
50+ (*FT_Glyph_TransformFunc)( FT_Glyph glyph,
51+ const FT_Matrix* matrix,
52+ const FT_Vector* delta );
53+
54+ typedef void
55+ (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph,
56+ FT_BBox* abbox );
57+
58+ typedef FT_Error
59+ (*FT_Glyph_CopyFunc)( FT_Glyph source,
60+ FT_Glyph target );
61+
62+ typedef FT_Error
63+ (*FT_Glyph_PrepareFunc)( FT_Glyph glyph,
64+ FT_GlyphSlot slot );
65+
66+/* deprecated */
67+#define FT_Glyph_Init_Func FT_Glyph_InitFunc
68+#define FT_Glyph_Done_Func FT_Glyph_DoneFunc
69+#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc
70+#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc
71+#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc
72+#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc
73+
74+
75+ struct FT_Glyph_Class_
76+ {
77+ FT_Long glyph_size;
78+ FT_Glyph_Format glyph_format;
79+
80+ FT_Glyph_InitFunc glyph_init;
81+ FT_Glyph_DoneFunc glyph_done;
82+ FT_Glyph_CopyFunc glyph_copy;
83+ FT_Glyph_TransformFunc glyph_transform;
84+ FT_Glyph_GetBBoxFunc glyph_bbox;
85+ FT_Glyph_PrepareFunc glyph_prepare;
86+ };
87+
88+
89+ typedef FT_Error
90+ (*FT_Renderer_RenderFunc)( FT_Renderer renderer,
91+ FT_GlyphSlot slot,
92+ FT_Render_Mode mode,
93+ const FT_Vector* origin );
94+
95+ typedef FT_Error
96+ (*FT_Renderer_TransformFunc)( FT_Renderer renderer,
97+ FT_GlyphSlot slot,
98+ const FT_Matrix* matrix,
99+ const FT_Vector* delta );
100+
101+
102+ typedef void
103+ (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer,
104+ FT_GlyphSlot slot,
105+ FT_BBox* cbox );
106+
107+
108+ typedef FT_Error
109+ (*FT_Renderer_SetModeFunc)( FT_Renderer renderer,
110+ FT_ULong mode_tag,
111+ FT_Pointer mode_ptr );
112+
113+/* deprecated identifiers */
114+#define FTRenderer_render FT_Renderer_RenderFunc
115+#define FTRenderer_transform FT_Renderer_TransformFunc
116+#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc
117+#define FTRenderer_setMode FT_Renderer_SetModeFunc
118+
119+
120+ /*************************************************************************/
121+ /* */
122+ /* <Struct> */
123+ /* FT_Renderer_Class */
124+ /* */
125+ /* <Description> */
126+ /* The renderer module class descriptor. */
127+ /* */
128+ /* <Fields> */
129+ /* root :: The root @FT_Module_Class fields. */
130+ /* */
131+ /* glyph_format :: The glyph image format this renderer handles. */
132+ /* */
133+ /* render_glyph :: A method used to render the image that is in a */
134+ /* given glyph slot into a bitmap. */
135+ /* */
136+ /* transform_glyph :: A method used to transform the image that is in */
137+ /* a given glyph slot. */
138+ /* */
139+ /* get_glyph_cbox :: A method used to access the glyph's cbox. */
140+ /* */
141+ /* set_mode :: A method used to pass additional parameters. */
142+ /* */
143+ /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */
144+ /* This is a pointer to its raster's class. */
145+ /* */
146+ typedef struct FT_Renderer_Class_
147+ {
148+ FT_Module_Class root;
149+
150+ FT_Glyph_Format glyph_format;
151+
152+ FT_Renderer_RenderFunc render_glyph;
153+ FT_Renderer_TransformFunc transform_glyph;
154+ FT_Renderer_GetCBoxFunc get_glyph_cbox;
155+ FT_Renderer_SetModeFunc set_mode;
156+
157+ FT_Raster_Funcs* raster_class;
158+
159+ } FT_Renderer_Class;
160+
161+
162+ /*************************************************************************/
163+ /* */
164+ /* <Function> */
165+ /* FT_Get_Renderer */
166+ /* */
167+ /* <Description> */
168+ /* Retrieve the current renderer for a given glyph format. */
169+ /* */
170+ /* <Input> */
171+ /* library :: A handle to the library object. */
172+ /* */
173+ /* format :: The glyph format. */
174+ /* */
175+ /* <Return> */
176+ /* A renderer handle. 0~if none found. */
177+ /* */
178+ /* <Note> */
179+ /* An error will be returned if a module already exists by that name, */
180+ /* or if the module requires a version of FreeType that is too great. */
181+ /* */
182+ /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */
183+ /* renderer by its name, use @FT_Get_Module. */
184+ /* */
185+ FT_EXPORT( FT_Renderer )
186+ FT_Get_Renderer( FT_Library library,
187+ FT_Glyph_Format format );
188+
189+
190+ /*************************************************************************/
191+ /* */
192+ /* <Function> */
193+ /* FT_Set_Renderer */
194+ /* */
195+ /* <Description> */
196+ /* Set the current renderer to use, and set additional mode. */
197+ /* */
198+ /* <InOut> */
199+ /* library :: A handle to the library object. */
200+ /* */
201+ /* <Input> */
202+ /* renderer :: A handle to the renderer object. */
203+ /* */
204+ /* num_params :: The number of additional parameters. */
205+ /* */
206+ /* parameters :: Additional parameters. */
207+ /* */
208+ /* <Return> */
209+ /* FreeType error code. 0~means success. */
210+ /* */
211+ /* <Note> */
212+ /* In case of success, the renderer will be used to convert glyph */
213+ /* images in the renderer's known format into bitmaps. */
214+ /* */
215+ /* This doesn't change the current renderer for other formats. */
216+ /* */
217+ /* Currently, no FreeType renderer module uses `parameters'; you */
218+ /* should thus always pass NULL as the value. */
219+ /* */
220+ FT_EXPORT( FT_Error )
221+ FT_Set_Renderer( FT_Library library,
222+ FT_Renderer renderer,
223+ FT_UInt num_params,
224+ FT_Parameter* parameters );
225+
226+ /* */
227+
228+
229+FT_END_HEADER
230+
231+#endif /* FTRENDER_H_ */
232+
233+
234+/* END */
1@@ -0,0 +1,159 @@
2+/***************************************************************************/
3+/* */
4+/* ftsizes.h */
5+/* */
6+/* FreeType size objects management (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+ /*************************************************************************/
21+ /* */
22+ /* Typical application would normally not need to use these functions. */
23+ /* However, they have been placed in a public API for the rare cases */
24+ /* where they are needed. */
25+ /* */
26+ /*************************************************************************/
27+
28+
29+#ifndef FTSIZES_H_
30+#define FTSIZES_H_
31+
32+
33+#include <ft2build.h>
34+#include FT_FREETYPE_H
35+
36+#ifdef FREETYPE_H
37+#error "freetype.h of FreeType 1 has been loaded!"
38+#error "Please fix the directory search order for header files"
39+#error "so that freetype.h of FreeType 2 is found first."
40+#endif
41+
42+
43+FT_BEGIN_HEADER
44+
45+
46+ /*************************************************************************/
47+ /* */
48+ /* <Section> */
49+ /* sizes_management */
50+ /* */
51+ /* <Title> */
52+ /* Size Management */
53+ /* */
54+ /* <Abstract> */
55+ /* Managing multiple sizes per face. */
56+ /* */
57+ /* <Description> */
58+ /* When creating a new face object (e.g., with @FT_New_Face), an */
59+ /* @FT_Size object is automatically created and used to store all */
60+ /* pixel-size dependent information, available in the `face->size' */
61+ /* field. */
62+ /* */
63+ /* It is however possible to create more sizes for a given face, */
64+ /* mostly in order to manage several character pixel sizes of the */
65+ /* same font family and style. See @FT_New_Size and @FT_Done_Size. */
66+ /* */
67+ /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */
68+ /* modify the contents of the current `active' size; you thus need */
69+ /* to use @FT_Activate_Size to change it. */
70+ /* */
71+ /* 99% of applications won't need the functions provided here, */
72+ /* especially if they use the caching sub-system, so be cautious */
73+ /* when using these. */
74+ /* */
75+ /*************************************************************************/
76+
77+
78+ /*************************************************************************/
79+ /* */
80+ /* <Function> */
81+ /* FT_New_Size */
82+ /* */
83+ /* <Description> */
84+ /* Create a new size object from a given face object. */
85+ /* */
86+ /* <Input> */
87+ /* face :: A handle to a parent face object. */
88+ /* */
89+ /* <Output> */
90+ /* asize :: A handle to a new size object. */
91+ /* */
92+ /* <Return> */
93+ /* FreeType error code. 0~means success. */
94+ /* */
95+ /* <Note> */
96+ /* You need to call @FT_Activate_Size in order to select the new size */
97+ /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */
98+ /* @FT_Load_Glyph, @FT_Load_Char, etc. */
99+ /* */
100+ FT_EXPORT( FT_Error )
101+ FT_New_Size( FT_Face face,
102+ FT_Size* size );
103+
104+
105+ /*************************************************************************/
106+ /* */
107+ /* <Function> */
108+ /* FT_Done_Size */
109+ /* */
110+ /* <Description> */
111+ /* Discard a given size object. Note that @FT_Done_Face */
112+ /* automatically discards all size objects allocated with */
113+ /* @FT_New_Size. */
114+ /* */
115+ /* <Input> */
116+ /* size :: A handle to a target size object. */
117+ /* */
118+ /* <Return> */
119+ /* FreeType error code. 0~means success. */
120+ /* */
121+ FT_EXPORT( FT_Error )
122+ FT_Done_Size( FT_Size size );
123+
124+
125+ /*************************************************************************/
126+ /* */
127+ /* <Function> */
128+ /* FT_Activate_Size */
129+ /* */
130+ /* <Description> */
131+ /* Even though it is possible to create several size objects for a */
132+ /* given face (see @FT_New_Size for details), functions like */
133+ /* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */
134+ /* activated last to determine the `current character pixel size'. */
135+ /* */
136+ /* This function can be used to `activate' a previously created size */
137+ /* object. */
138+ /* */
139+ /* <Input> */
140+ /* size :: A handle to a target size object. */
141+ /* */
142+ /* <Return> */
143+ /* FreeType error code. 0~means success. */
144+ /* */
145+ /* <Note> */
146+ /* If `face' is the size's parent face object, this function changes */
147+ /* the value of `face->size' to the input size handle. */
148+ /* */
149+ FT_EXPORT( FT_Error )
150+ FT_Activate_Size( FT_Size size );
151+
152+ /* */
153+
154+
155+FT_END_HEADER
156+
157+#endif /* FTSIZES_H_ */
158+
159+
160+/* END */
1@@ -0,0 +1,253 @@
2+/***************************************************************************/
3+/* */
4+/* ftsnames.h */
5+/* */
6+/* Simple interface to access SFNT `name' tables (which are used */
7+/* to hold font names, copyright info, notices, etc.) (specification). */
8+/* */
9+/* This is _not_ used to retrieve glyph names! */
10+/* */
11+/* Copyright 1996-2018 by */
12+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
13+/* */
14+/* This file is part of the FreeType project, and may only be used, */
15+/* modified, and distributed under the terms of the FreeType project */
16+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
17+/* this file you indicate that you have read the license and */
18+/* understand and accept it fully. */
19+/* */
20+/***************************************************************************/
21+
22+
23+#ifndef FTSNAMES_H_
24+#define FTSNAMES_H_
25+
26+
27+#include <ft2build.h>
28+#include FT_FREETYPE_H
29+#include FT_PARAMETER_TAGS_H
30+
31+#ifdef FREETYPE_H
32+#error "freetype.h of FreeType 1 has been loaded!"
33+#error "Please fix the directory search order for header files"
34+#error "so that freetype.h of FreeType 2 is found first."
35+#endif
36+
37+
38+FT_BEGIN_HEADER
39+
40+
41+ /*************************************************************************/
42+ /* */
43+ /* <Section> */
44+ /* sfnt_names */
45+ /* */
46+ /* <Title> */
47+ /* SFNT Names */
48+ /* */
49+ /* <Abstract> */
50+ /* Access the names embedded in TrueType and OpenType files. */
51+ /* */
52+ /* <Description> */
53+ /* The TrueType and OpenType specifications allow the inclusion of */
54+ /* a special names table (`name') in font files. This table contains */
55+ /* textual (and internationalized) information regarding the font, */
56+ /* like family name, copyright, version, etc. */
57+ /* */
58+ /* The definitions below are used to access them if available. */
59+ /* */
60+ /* Note that this has nothing to do with glyph names! */
61+ /* */
62+ /*************************************************************************/
63+
64+
65+ /*************************************************************************/
66+ /* */
67+ /* <Struct> */
68+ /* FT_SfntName */
69+ /* */
70+ /* <Description> */
71+ /* A structure used to model an SFNT `name' table entry. */
72+ /* */
73+ /* <Fields> */
74+ /* platform_id :: The platform ID for `string'. */
75+ /* See @TT_PLATFORM_XXX for possible values. */
76+ /* */
77+ /* encoding_id :: The encoding ID for `string'. */
78+ /* See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */
79+ /* @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX */
80+ /* for possible values. */
81+ /* */
82+ /* language_id :: The language ID for `string'. */
83+ /* See @TT_MAC_LANGID_XXX and @TT_MS_LANGID_XXX for */
84+ /* possible values. */
85+ /* */
86+ /* Registered OpenType values for `language_id' are */
87+ /* always smaller than 0x8000; values equal or larger */
88+ /* than 0x8000 usually indicate a language tag string */
89+ /* (introduced in OpenType version 1.6). Use function */
90+ /* @FT_Get_Sfnt_LangTag with `language_id' as its */
91+ /* argument to retrieve the associated language tag. */
92+ /* */
93+ /* name_id :: An identifier for `string'. */
94+ /* See @TT_NAME_ID_XXX for possible values. */
95+ /* */
96+ /* string :: The `name' string. Note that its format differs */
97+ /* depending on the (platform,encoding) pair, being */
98+ /* either a string of bytes (without a terminating */
99+ /* NULL byte) or containing UTF-16BE entities. */
100+ /* */
101+ /* string_len :: The length of `string' in bytes. */
102+ /* */
103+ /* <Note> */
104+ /* Please refer to the TrueType or OpenType specification for more */
105+ /* details. */
106+ /* */
107+ typedef struct FT_SfntName_
108+ {
109+ FT_UShort platform_id;
110+ FT_UShort encoding_id;
111+ FT_UShort language_id;
112+ FT_UShort name_id;
113+
114+ FT_Byte* string; /* this string is *not* null-terminated! */
115+ FT_UInt string_len; /* in bytes */
116+
117+ } FT_SfntName;
118+
119+
120+ /*************************************************************************/
121+ /* */
122+ /* <Function> */
123+ /* FT_Get_Sfnt_Name_Count */
124+ /* */
125+ /* <Description> */
126+ /* Retrieve the number of name strings in the SFNT `name' table. */
127+ /* */
128+ /* <Input> */
129+ /* face :: A handle to the source face. */
130+ /* */
131+ /* <Return> */
132+ /* The number of strings in the `name' table. */
133+ /* */
134+ FT_EXPORT( FT_UInt )
135+ FT_Get_Sfnt_Name_Count( FT_Face face );
136+
137+
138+ /*************************************************************************/
139+ /* */
140+ /* <Function> */
141+ /* FT_Get_Sfnt_Name */
142+ /* */
143+ /* <Description> */
144+ /* Retrieve a string of the SFNT `name' table for a given index. */
145+ /* */
146+ /* <Input> */
147+ /* face :: A handle to the source face. */
148+ /* */
149+ /* idx :: The index of the `name' string. */
150+ /* */
151+ /* <Output> */
152+ /* aname :: The indexed @FT_SfntName structure. */
153+ /* */
154+ /* <Return> */
155+ /* FreeType error code. 0~means success. */
156+ /* */
157+ /* <Note> */
158+ /* The `string' array returned in the `aname' structure is not */
159+ /* null-terminated. Note that you don't have to deallocate `string' */
160+ /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */
161+ /* */
162+ /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */
163+ /* `name' table entries, then do a loop until you get the right */
164+ /* platform, encoding, and name ID. */
165+ /* */
166+ /* `name' table format~1 entries can use language tags also, see */
167+ /* @FT_Get_Sfnt_LangTag. */
168+ /* */
169+ FT_EXPORT( FT_Error )
170+ FT_Get_Sfnt_Name( FT_Face face,
171+ FT_UInt idx,
172+ FT_SfntName *aname );
173+
174+
175+ /*************************************************************************/
176+ /* */
177+ /* <Struct> */
178+ /* FT_SfntLangTag */
179+ /* */
180+ /* <Description> */
181+ /* A structure to model a language tag entry from an SFNT `name' */
182+ /* table. */
183+ /* */
184+ /* <Fields> */
185+ /* string :: The language tag string, encoded in UTF-16BE */
186+ /* (without trailing NULL bytes). */
187+ /* */
188+ /* string_len :: The length of `string' in *bytes*. */
189+ /* */
190+ /* <Note> */
191+ /* Please refer to the TrueType or OpenType specification for more */
192+ /* details. */
193+ /* */
194+ /* <Since> */
195+ /* 2.8 */
196+ /* */
197+ typedef struct FT_SfntLangTag_
198+ {
199+ FT_Byte* string; /* this string is *not* null-terminated! */
200+ FT_UInt string_len; /* in bytes */
201+
202+ } FT_SfntLangTag;
203+
204+
205+ /*************************************************************************/
206+ /* */
207+ /* <Function> */
208+ /* FT_Get_Sfnt_LangTag */
209+ /* */
210+ /* <Description> */
211+ /* Retrieve the language tag associated with a language ID of an SFNT */
212+ /* `name' table entry. */
213+ /* */
214+ /* <Input> */
215+ /* face :: A handle to the source face. */
216+ /* */
217+ /* langID :: The language ID, as returned by @FT_Get_Sfnt_Name. */
218+ /* This is always a value larger than 0x8000. */
219+ /* */
220+ /* <Output> */
221+ /* alangTag :: The language tag associated with the `name' table */
222+ /* entry's language ID. */
223+ /* */
224+ /* <Return> */
225+ /* FreeType error code. 0~means success. */
226+ /* */
227+ /* <Note> */
228+ /* The `string' array returned in the `alangTag' structure is not */
229+ /* null-terminated. Note that you don't have to deallocate `string' */
230+ /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */
231+ /* */
232+ /* Only `name' table format~1 supports language tags. For format~0 */
233+ /* tables, this function always returns FT_Err_Invalid_Table. For */
234+ /* invalid format~1 language ID values, FT_Err_Invalid_Argument is */
235+ /* returned. */
236+ /* */
237+ /* <Since> */
238+ /* 2.8 */
239+ /* */
240+ FT_EXPORT( FT_Error )
241+ FT_Get_Sfnt_LangTag( FT_Face face,
242+ FT_UInt langID,
243+ FT_SfntLangTag *alangTag );
244+
245+
246+ /* */
247+
248+
249+FT_END_HEADER
250+
251+#endif /* FTSNAMES_H_ */
252+
253+
254+/* END */
1@@ -0,0 +1,785 @@
2+/***************************************************************************/
3+/* */
4+/* ftstroke.h */
5+/* */
6+/* FreeType path stroker (specification). */
7+/* */
8+/* Copyright 2002-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTSTROKE_H_
21+#define FTSTROKE_H_
22+
23+#include <ft2build.h>
24+#include FT_OUTLINE_H
25+#include FT_GLYPH_H
26+
27+
28+FT_BEGIN_HEADER
29+
30+
31+ /************************************************************************
32+ *
33+ * @section:
34+ * glyph_stroker
35+ *
36+ * @title:
37+ * Glyph Stroker
38+ *
39+ * @abstract:
40+ * Generating bordered and stroked glyphs.
41+ *
42+ * @description:
43+ * This component generates stroked outlines of a given vectorial
44+ * glyph. It also allows you to retrieve the `outside' and/or the
45+ * `inside' borders of the stroke.
46+ *
47+ * This can be useful to generate `bordered' glyph, i.e., glyphs
48+ * displayed with a coloured (and anti-aliased) border around their
49+ * shape.
50+ *
51+ * @order:
52+ * FT_Stroker
53+ *
54+ * FT_Stroker_LineJoin
55+ * FT_Stroker_LineCap
56+ * FT_StrokerBorder
57+ *
58+ * FT_Outline_GetInsideBorder
59+ * FT_Outline_GetOutsideBorder
60+ *
61+ * FT_Glyph_Stroke
62+ * FT_Glyph_StrokeBorder
63+ *
64+ * FT_Stroker_New
65+ * FT_Stroker_Set
66+ * FT_Stroker_Rewind
67+ * FT_Stroker_ParseOutline
68+ * FT_Stroker_Done
69+ *
70+ * FT_Stroker_BeginSubPath
71+ * FT_Stroker_EndSubPath
72+ *
73+ * FT_Stroker_LineTo
74+ * FT_Stroker_ConicTo
75+ * FT_Stroker_CubicTo
76+ *
77+ * FT_Stroker_GetBorderCounts
78+ * FT_Stroker_ExportBorder
79+ * FT_Stroker_GetCounts
80+ * FT_Stroker_Export
81+ *
82+ */
83+
84+
85+ /**************************************************************
86+ *
87+ * @type:
88+ * FT_Stroker
89+ *
90+ * @description:
91+ * Opaque handle to a path stroker object.
92+ */
93+ typedef struct FT_StrokerRec_* FT_Stroker;
94+
95+
96+ /**************************************************************
97+ *
98+ * @enum:
99+ * FT_Stroker_LineJoin
100+ *
101+ * @description:
102+ * These values determine how two joining lines are rendered
103+ * in a stroker.
104+ *
105+ * @values:
106+ * FT_STROKER_LINEJOIN_ROUND ::
107+ * Used to render rounded line joins. Circular arcs are used
108+ * to join two lines smoothly.
109+ *
110+ * FT_STROKER_LINEJOIN_BEVEL ::
111+ * Used to render beveled line joins. The outer corner of
112+ * the joined lines is filled by enclosing the triangular
113+ * region of the corner with a straight line between the
114+ * outer corners of each stroke.
115+ *
116+ * FT_STROKER_LINEJOIN_MITER_FIXED ::
117+ * Used to render mitered line joins, with fixed bevels if the
118+ * miter limit is exceeded. The outer edges of the strokes
119+ * for the two segments are extended until they meet at an
120+ * angle. If the segments meet at too sharp an angle (such
121+ * that the miter would extend from the intersection of the
122+ * segments a distance greater than the product of the miter
123+ * limit value and the border radius), then a bevel join (see
124+ * above) is used instead. This prevents long spikes being
125+ * created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter
126+ * line join as used in PostScript and PDF.
127+ *
128+ * FT_STROKER_LINEJOIN_MITER_VARIABLE ::
129+ * FT_STROKER_LINEJOIN_MITER ::
130+ * Used to render mitered line joins, with variable bevels if
131+ * the miter limit is exceeded. The intersection of the
132+ * strokes is clipped at a line perpendicular to the bisector
133+ * of the angle between the strokes, at the distance from the
134+ * intersection of the segments equal to the product of the
135+ * miter limit value and the border radius. This prevents
136+ * long spikes being created.
137+ * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line
138+ * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias
139+ * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for
140+ * backward compatibility.
141+ */
142+ typedef enum FT_Stroker_LineJoin_
143+ {
144+ FT_STROKER_LINEJOIN_ROUND = 0,
145+ FT_STROKER_LINEJOIN_BEVEL = 1,
146+ FT_STROKER_LINEJOIN_MITER_VARIABLE = 2,
147+ FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE,
148+ FT_STROKER_LINEJOIN_MITER_FIXED = 3
149+
150+ } FT_Stroker_LineJoin;
151+
152+
153+ /**************************************************************
154+ *
155+ * @enum:
156+ * FT_Stroker_LineCap
157+ *
158+ * @description:
159+ * These values determine how the end of opened sub-paths are
160+ * rendered in a stroke.
161+ *
162+ * @values:
163+ * FT_STROKER_LINECAP_BUTT ::
164+ * The end of lines is rendered as a full stop on the last
165+ * point itself.
166+ *
167+ * FT_STROKER_LINECAP_ROUND ::
168+ * The end of lines is rendered as a half-circle around the
169+ * last point.
170+ *
171+ * FT_STROKER_LINECAP_SQUARE ::
172+ * The end of lines is rendered as a square around the
173+ * last point.
174+ */
175+ typedef enum FT_Stroker_LineCap_
176+ {
177+ FT_STROKER_LINECAP_BUTT = 0,
178+ FT_STROKER_LINECAP_ROUND,
179+ FT_STROKER_LINECAP_SQUARE
180+
181+ } FT_Stroker_LineCap;
182+
183+
184+ /**************************************************************
185+ *
186+ * @enum:
187+ * FT_StrokerBorder
188+ *
189+ * @description:
190+ * These values are used to select a given stroke border
191+ * in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder.
192+ *
193+ * @values:
194+ * FT_STROKER_BORDER_LEFT ::
195+ * Select the left border, relative to the drawing direction.
196+ *
197+ * FT_STROKER_BORDER_RIGHT ::
198+ * Select the right border, relative to the drawing direction.
199+ *
200+ * @note:
201+ * Applications are generally interested in the `inside' and `outside'
202+ * borders. However, there is no direct mapping between these and the
203+ * `left' and `right' ones, since this really depends on the glyph's
204+ * drawing orientation, which varies between font formats.
205+ *
206+ * You can however use @FT_Outline_GetInsideBorder and
207+ * @FT_Outline_GetOutsideBorder to get these.
208+ */
209+ typedef enum FT_StrokerBorder_
210+ {
211+ FT_STROKER_BORDER_LEFT = 0,
212+ FT_STROKER_BORDER_RIGHT
213+
214+ } FT_StrokerBorder;
215+
216+
217+ /**************************************************************
218+ *
219+ * @function:
220+ * FT_Outline_GetInsideBorder
221+ *
222+ * @description:
223+ * Retrieve the @FT_StrokerBorder value corresponding to the
224+ * `inside' borders of a given outline.
225+ *
226+ * @input:
227+ * outline ::
228+ * The source outline handle.
229+ *
230+ * @return:
231+ * The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid
232+ * outlines.
233+ */
234+ FT_EXPORT( FT_StrokerBorder )
235+ FT_Outline_GetInsideBorder( FT_Outline* outline );
236+
237+
238+ /**************************************************************
239+ *
240+ * @function:
241+ * FT_Outline_GetOutsideBorder
242+ *
243+ * @description:
244+ * Retrieve the @FT_StrokerBorder value corresponding to the
245+ * `outside' borders of a given outline.
246+ *
247+ * @input:
248+ * outline ::
249+ * The source outline handle.
250+ *
251+ * @return:
252+ * The border index. @FT_STROKER_BORDER_LEFT for empty or invalid
253+ * outlines.
254+ */
255+ FT_EXPORT( FT_StrokerBorder )
256+ FT_Outline_GetOutsideBorder( FT_Outline* outline );
257+
258+
259+ /**************************************************************
260+ *
261+ * @function:
262+ * FT_Stroker_New
263+ *
264+ * @description:
265+ * Create a new stroker object.
266+ *
267+ * @input:
268+ * library ::
269+ * FreeType library handle.
270+ *
271+ * @output:
272+ * astroker ::
273+ * A new stroker object handle. NULL in case of error.
274+ *
275+ * @return:
276+ * FreeType error code. 0~means success.
277+ */
278+ FT_EXPORT( FT_Error )
279+ FT_Stroker_New( FT_Library library,
280+ FT_Stroker *astroker );
281+
282+
283+ /**************************************************************
284+ *
285+ * @function:
286+ * FT_Stroker_Set
287+ *
288+ * @description:
289+ * Reset a stroker object's attributes.
290+ *
291+ * @input:
292+ * stroker ::
293+ * The target stroker handle.
294+ *
295+ * radius ::
296+ * The border radius.
297+ *
298+ * line_cap ::
299+ * The line cap style.
300+ *
301+ * line_join ::
302+ * The line join style.
303+ *
304+ * miter_limit ::
305+ * The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and
306+ * FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles,
307+ * expressed as 16.16 fixed-point value.
308+ *
309+ * @note:
310+ * The radius is expressed in the same units as the outline
311+ * coordinates.
312+ *
313+ * This function calls @FT_Stroker_Rewind automatically.
314+ */
315+ FT_EXPORT( void )
316+ FT_Stroker_Set( FT_Stroker stroker,
317+ FT_Fixed radius,
318+ FT_Stroker_LineCap line_cap,
319+ FT_Stroker_LineJoin line_join,
320+ FT_Fixed miter_limit );
321+
322+
323+ /**************************************************************
324+ *
325+ * @function:
326+ * FT_Stroker_Rewind
327+ *
328+ * @description:
329+ * Reset a stroker object without changing its attributes.
330+ * You should call this function before beginning a new
331+ * series of calls to @FT_Stroker_BeginSubPath or
332+ * @FT_Stroker_EndSubPath.
333+ *
334+ * @input:
335+ * stroker ::
336+ * The target stroker handle.
337+ */
338+ FT_EXPORT( void )
339+ FT_Stroker_Rewind( FT_Stroker stroker );
340+
341+
342+ /**************************************************************
343+ *
344+ * @function:
345+ * FT_Stroker_ParseOutline
346+ *
347+ * @description:
348+ * A convenience function used to parse a whole outline with
349+ * the stroker. The resulting outline(s) can be retrieved
350+ * later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export.
351+ *
352+ * @input:
353+ * stroker ::
354+ * The target stroker handle.
355+ *
356+ * outline ::
357+ * The source outline.
358+ *
359+ * opened ::
360+ * A boolean. If~1, the outline is treated as an open path instead
361+ * of a closed one.
362+ *
363+ * @return:
364+ * FreeType error code. 0~means success.
365+ *
366+ * @note:
367+ * If `opened' is~0 (the default), the outline is treated as a closed
368+ * path, and the stroker generates two distinct `border' outlines.
369+ *
370+ * If `opened' is~1, the outline is processed as an open path, and the
371+ * stroker generates a single `stroke' outline.
372+ *
373+ * This function calls @FT_Stroker_Rewind automatically.
374+ */
375+ FT_EXPORT( FT_Error )
376+ FT_Stroker_ParseOutline( FT_Stroker stroker,
377+ FT_Outline* outline,
378+ FT_Bool opened );
379+
380+
381+ /**************************************************************
382+ *
383+ * @function:
384+ * FT_Stroker_BeginSubPath
385+ *
386+ * @description:
387+ * Start a new sub-path in the stroker.
388+ *
389+ * @input:
390+ * stroker ::
391+ * The target stroker handle.
392+ *
393+ * to ::
394+ * A pointer to the start vector.
395+ *
396+ * open ::
397+ * A boolean. If~1, the sub-path is treated as an open one.
398+ *
399+ * @return:
400+ * FreeType error code. 0~means success.
401+ *
402+ * @note:
403+ * This function is useful when you need to stroke a path that is
404+ * not stored as an @FT_Outline object.
405+ */
406+ FT_EXPORT( FT_Error )
407+ FT_Stroker_BeginSubPath( FT_Stroker stroker,
408+ FT_Vector* to,
409+ FT_Bool open );
410+
411+
412+ /**************************************************************
413+ *
414+ * @function:
415+ * FT_Stroker_EndSubPath
416+ *
417+ * @description:
418+ * Close the current sub-path in the stroker.
419+ *
420+ * @input:
421+ * stroker ::
422+ * The target stroker handle.
423+ *
424+ * @return:
425+ * FreeType error code. 0~means success.
426+ *
427+ * @note:
428+ * You should call this function after @FT_Stroker_BeginSubPath.
429+ * If the subpath was not `opened', this function `draws' a
430+ * single line segment to the start position when needed.
431+ */
432+ FT_EXPORT( FT_Error )
433+ FT_Stroker_EndSubPath( FT_Stroker stroker );
434+
435+
436+ /**************************************************************
437+ *
438+ * @function:
439+ * FT_Stroker_LineTo
440+ *
441+ * @description:
442+ * `Draw' a single line segment in the stroker's current sub-path,
443+ * from the last position.
444+ *
445+ * @input:
446+ * stroker ::
447+ * The target stroker handle.
448+ *
449+ * to ::
450+ * A pointer to the destination point.
451+ *
452+ * @return:
453+ * FreeType error code. 0~means success.
454+ *
455+ * @note:
456+ * You should call this function between @FT_Stroker_BeginSubPath and
457+ * @FT_Stroker_EndSubPath.
458+ */
459+ FT_EXPORT( FT_Error )
460+ FT_Stroker_LineTo( FT_Stroker stroker,
461+ FT_Vector* to );
462+
463+
464+ /**************************************************************
465+ *
466+ * @function:
467+ * FT_Stroker_ConicTo
468+ *
469+ * @description:
470+ * `Draw' a single quadratic Bezier in the stroker's current sub-path,
471+ * from the last position.
472+ *
473+ * @input:
474+ * stroker ::
475+ * The target stroker handle.
476+ *
477+ * control ::
478+ * A pointer to a Bezier control point.
479+ *
480+ * to ::
481+ * A pointer to the destination point.
482+ *
483+ * @return:
484+ * FreeType error code. 0~means success.
485+ *
486+ * @note:
487+ * You should call this function between @FT_Stroker_BeginSubPath and
488+ * @FT_Stroker_EndSubPath.
489+ */
490+ FT_EXPORT( FT_Error )
491+ FT_Stroker_ConicTo( FT_Stroker stroker,
492+ FT_Vector* control,
493+ FT_Vector* to );
494+
495+
496+ /**************************************************************
497+ *
498+ * @function:
499+ * FT_Stroker_CubicTo
500+ *
501+ * @description:
502+ * `Draw' a single cubic Bezier in the stroker's current sub-path,
503+ * from the last position.
504+ *
505+ * @input:
506+ * stroker ::
507+ * The target stroker handle.
508+ *
509+ * control1 ::
510+ * A pointer to the first Bezier control point.
511+ *
512+ * control2 ::
513+ * A pointer to second Bezier control point.
514+ *
515+ * to ::
516+ * A pointer to the destination point.
517+ *
518+ * @return:
519+ * FreeType error code. 0~means success.
520+ *
521+ * @note:
522+ * You should call this function between @FT_Stroker_BeginSubPath and
523+ * @FT_Stroker_EndSubPath.
524+ */
525+ FT_EXPORT( FT_Error )
526+ FT_Stroker_CubicTo( FT_Stroker stroker,
527+ FT_Vector* control1,
528+ FT_Vector* control2,
529+ FT_Vector* to );
530+
531+
532+ /**************************************************************
533+ *
534+ * @function:
535+ * FT_Stroker_GetBorderCounts
536+ *
537+ * @description:
538+ * Call this function once you have finished parsing your paths
539+ * with the stroker. It returns the number of points and
540+ * contours necessary to export one of the `border' or `stroke'
541+ * outlines generated by the stroker.
542+ *
543+ * @input:
544+ * stroker ::
545+ * The target stroker handle.
546+ *
547+ * border ::
548+ * The border index.
549+ *
550+ * @output:
551+ * anum_points ::
552+ * The number of points.
553+ *
554+ * anum_contours ::
555+ * The number of contours.
556+ *
557+ * @return:
558+ * FreeType error code. 0~means success.
559+ *
560+ * @note:
561+ * When an outline, or a sub-path, is `closed', the stroker generates
562+ * two independent `border' outlines, named `left' and `right'.
563+ *
564+ * When the outline, or a sub-path, is `opened', the stroker merges
565+ * the `border' outlines with caps. The `left' border receives all
566+ * points, while the `right' border becomes empty.
567+ *
568+ * Use the function @FT_Stroker_GetCounts instead if you want to
569+ * retrieve the counts associated to both borders.
570+ */
571+ FT_EXPORT( FT_Error )
572+ FT_Stroker_GetBorderCounts( FT_Stroker stroker,
573+ FT_StrokerBorder border,
574+ FT_UInt *anum_points,
575+ FT_UInt *anum_contours );
576+
577+
578+ /**************************************************************
579+ *
580+ * @function:
581+ * FT_Stroker_ExportBorder
582+ *
583+ * @description:
584+ * Call this function after @FT_Stroker_GetBorderCounts to
585+ * export the corresponding border to your own @FT_Outline
586+ * structure.
587+ *
588+ * Note that this function appends the border points and
589+ * contours to your outline, but does not try to resize its
590+ * arrays.
591+ *
592+ * @input:
593+ * stroker ::
594+ * The target stroker handle.
595+ *
596+ * border ::
597+ * The border index.
598+ *
599+ * outline ::
600+ * The target outline handle.
601+ *
602+ * @note:
603+ * Always call this function after @FT_Stroker_GetBorderCounts to
604+ * get sure that there is enough room in your @FT_Outline object to
605+ * receive all new data.
606+ *
607+ * When an outline, or a sub-path, is `closed', the stroker generates
608+ * two independent `border' outlines, named `left' and `right'.
609+ *
610+ * When the outline, or a sub-path, is `opened', the stroker merges
611+ * the `border' outlines with caps. The `left' border receives all
612+ * points, while the `right' border becomes empty.
613+ *
614+ * Use the function @FT_Stroker_Export instead if you want to
615+ * retrieve all borders at once.
616+ */
617+ FT_EXPORT( void )
618+ FT_Stroker_ExportBorder( FT_Stroker stroker,
619+ FT_StrokerBorder border,
620+ FT_Outline* outline );
621+
622+
623+ /**************************************************************
624+ *
625+ * @function:
626+ * FT_Stroker_GetCounts
627+ *
628+ * @description:
629+ * Call this function once you have finished parsing your paths
630+ * with the stroker. It returns the number of points and
631+ * contours necessary to export all points/borders from the stroked
632+ * outline/path.
633+ *
634+ * @input:
635+ * stroker ::
636+ * The target stroker handle.
637+ *
638+ * @output:
639+ * anum_points ::
640+ * The number of points.
641+ *
642+ * anum_contours ::
643+ * The number of contours.
644+ *
645+ * @return:
646+ * FreeType error code. 0~means success.
647+ */
648+ FT_EXPORT( FT_Error )
649+ FT_Stroker_GetCounts( FT_Stroker stroker,
650+ FT_UInt *anum_points,
651+ FT_UInt *anum_contours );
652+
653+
654+ /**************************************************************
655+ *
656+ * @function:
657+ * FT_Stroker_Export
658+ *
659+ * @description:
660+ * Call this function after @FT_Stroker_GetBorderCounts to
661+ * export all borders to your own @FT_Outline structure.
662+ *
663+ * Note that this function appends the border points and
664+ * contours to your outline, but does not try to resize its
665+ * arrays.
666+ *
667+ * @input:
668+ * stroker ::
669+ * The target stroker handle.
670+ *
671+ * outline ::
672+ * The target outline handle.
673+ */
674+ FT_EXPORT( void )
675+ FT_Stroker_Export( FT_Stroker stroker,
676+ FT_Outline* outline );
677+
678+
679+ /**************************************************************
680+ *
681+ * @function:
682+ * FT_Stroker_Done
683+ *
684+ * @description:
685+ * Destroy a stroker object.
686+ *
687+ * @input:
688+ * stroker ::
689+ * A stroker handle. Can be NULL.
690+ */
691+ FT_EXPORT( void )
692+ FT_Stroker_Done( FT_Stroker stroker );
693+
694+
695+ /**************************************************************
696+ *
697+ * @function:
698+ * FT_Glyph_Stroke
699+ *
700+ * @description:
701+ * Stroke a given outline glyph object with a given stroker.
702+ *
703+ * @inout:
704+ * pglyph ::
705+ * Source glyph handle on input, new glyph handle on output.
706+ *
707+ * @input:
708+ * stroker ::
709+ * A stroker handle.
710+ *
711+ * destroy ::
712+ * A Boolean. If~1, the source glyph object is destroyed
713+ * on success.
714+ *
715+ * @return:
716+ * FreeType error code. 0~means success.
717+ *
718+ * @note:
719+ * The source glyph is untouched in case of error.
720+ *
721+ * Adding stroke may yield a significantly wider and taller glyph
722+ * depending on how large of a radius was used to stroke the glyph. You
723+ * may need to manually adjust horizontal and vertical advance amounts
724+ * to account for this added size.
725+ */
726+ FT_EXPORT( FT_Error )
727+ FT_Glyph_Stroke( FT_Glyph *pglyph,
728+ FT_Stroker stroker,
729+ FT_Bool destroy );
730+
731+
732+ /**************************************************************
733+ *
734+ * @function:
735+ * FT_Glyph_StrokeBorder
736+ *
737+ * @description:
738+ * Stroke a given outline glyph object with a given stroker, but
739+ * only return either its inside or outside border.
740+ *
741+ * @inout:
742+ * pglyph ::
743+ * Source glyph handle on input, new glyph handle on output.
744+ *
745+ * @input:
746+ * stroker ::
747+ * A stroker handle.
748+ *
749+ * inside ::
750+ * A Boolean. If~1, return the inside border, otherwise
751+ * the outside border.
752+ *
753+ * destroy ::
754+ * A Boolean. If~1, the source glyph object is destroyed
755+ * on success.
756+ *
757+ * @return:
758+ * FreeType error code. 0~means success.
759+ *
760+ * @note:
761+ * The source glyph is untouched in case of error.
762+ *
763+ * Adding stroke may yield a significantly wider and taller glyph
764+ * depending on how large of a radius was used to stroke the glyph. You
765+ * may need to manually adjust horizontal and vertical advance amounts
766+ * to account for this added size.
767+ */
768+ FT_EXPORT( FT_Error )
769+ FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
770+ FT_Stroker stroker,
771+ FT_Bool inside,
772+ FT_Bool destroy );
773+
774+ /* */
775+
776+FT_END_HEADER
777+
778+#endif /* FTSTROKE_H_ */
779+
780+
781+/* END */
782+
783+
784+/* Local Variables: */
785+/* coding: utf-8 */
786+/* End: */
1@@ -0,0 +1,84 @@
2+/***************************************************************************/
3+/* */
4+/* ftsynth.h */
5+/* */
6+/* FreeType synthesizing code for emboldening and slanting */
7+/* (specification). */
8+/* */
9+/* Copyright 2000-2018 by */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+
21+ /*************************************************************************/
22+ /*************************************************************************/
23+ /*************************************************************************/
24+ /*************************************************************************/
25+ /*************************************************************************/
26+ /********* *********/
27+ /********* WARNING, THIS IS ALPHA CODE! THIS API *********/
28+ /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
29+ /********* FREETYPE DEVELOPMENT TEAM *********/
30+ /********* *********/
31+ /*************************************************************************/
32+ /*************************************************************************/
33+ /*************************************************************************/
34+ /*************************************************************************/
35+ /*************************************************************************/
36+
37+
38+ /* Main reason for not lifting the functions in this module to a */
39+ /* `standard' API is that the used parameters for emboldening and */
40+ /* slanting are not configurable. Consider the functions as a */
41+ /* code resource that should be copied into the application and */
42+ /* adapted to the particular needs. */
43+
44+
45+#ifndef FTSYNTH_H_
46+#define FTSYNTH_H_
47+
48+
49+#include <ft2build.h>
50+#include FT_FREETYPE_H
51+
52+#ifdef FREETYPE_H
53+#error "freetype.h of FreeType 1 has been loaded!"
54+#error "Please fix the directory search order for header files"
55+#error "so that freetype.h of FreeType 2 is found first."
56+#endif
57+
58+
59+FT_BEGIN_HEADER
60+
61+ /* Embolden a glyph by a `reasonable' value (which is highly a matter of */
62+ /* taste). This function is actually a convenience function, providing */
63+ /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */
64+ /* */
65+ /* For emboldened outlines the height, width, and advance metrics are */
66+ /* increased by the strength of the emboldening -- this even affects */
67+ /* mono-width fonts! */
68+ /* */
69+ /* You can also call @FT_Outline_Get_CBox to get precise values. */
70+ FT_EXPORT( void )
71+ FT_GlyphSlot_Embolden( FT_GlyphSlot slot );
72+
73+ /* Slant an outline glyph to the right by about 12 degrees. */
74+ FT_EXPORT( void )
75+ FT_GlyphSlot_Oblique( FT_GlyphSlot slot );
76+
77+ /* */
78+
79+
80+FT_END_HEADER
81+
82+#endif /* FTSYNTH_H_ */
83+
84+
85+/* END */
1@@ -0,0 +1,355 @@
2+/***************************************************************************/
3+/* */
4+/* ftsystem.h */
5+/* */
6+/* FreeType low-level system interface definition (specification). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTSYSTEM_H_
21+#define FTSYSTEM_H_
22+
23+
24+#include <ft2build.h>
25+
26+
27+FT_BEGIN_HEADER
28+
29+
30+ /*************************************************************************/
31+ /* */
32+ /* <Section> */
33+ /* system_interface */
34+ /* */
35+ /* <Title> */
36+ /* System Interface */
37+ /* */
38+ /* <Abstract> */
39+ /* How FreeType manages memory and i/o. */
40+ /* */
41+ /* <Description> */
42+ /* This section contains various definitions related to memory */
43+ /* management and i/o access. You need to understand this */
44+ /* information if you want to use a custom memory manager or you own */
45+ /* i/o streams. */
46+ /* */
47+ /*************************************************************************/
48+
49+
50+ /*************************************************************************/
51+ /* */
52+ /* M E M O R Y M A N A G E M E N T */
53+ /* */
54+ /*************************************************************************/
55+
56+
57+ /*************************************************************************
58+ *
59+ * @type:
60+ * FT_Memory
61+ *
62+ * @description:
63+ * A handle to a given memory manager object, defined with an
64+ * @FT_MemoryRec structure.
65+ *
66+ */
67+ typedef struct FT_MemoryRec_* FT_Memory;
68+
69+
70+ /*************************************************************************
71+ *
72+ * @functype:
73+ * FT_Alloc_Func
74+ *
75+ * @description:
76+ * A function used to allocate `size' bytes from `memory'.
77+ *
78+ * @input:
79+ * memory ::
80+ * A handle to the source memory manager.
81+ *
82+ * size ::
83+ * The size in bytes to allocate.
84+ *
85+ * @return:
86+ * Address of new memory block. 0~in case of failure.
87+ *
88+ */
89+ typedef void*
90+ (*FT_Alloc_Func)( FT_Memory memory,
91+ long size );
92+
93+
94+ /*************************************************************************
95+ *
96+ * @functype:
97+ * FT_Free_Func
98+ *
99+ * @description:
100+ * A function used to release a given block of memory.
101+ *
102+ * @input:
103+ * memory ::
104+ * A handle to the source memory manager.
105+ *
106+ * block ::
107+ * The address of the target memory block.
108+ *
109+ */
110+ typedef void
111+ (*FT_Free_Func)( FT_Memory memory,
112+ void* block );
113+
114+
115+ /*************************************************************************
116+ *
117+ * @functype:
118+ * FT_Realloc_Func
119+ *
120+ * @description:
121+ * A function used to re-allocate a given block of memory.
122+ *
123+ * @input:
124+ * memory ::
125+ * A handle to the source memory manager.
126+ *
127+ * cur_size ::
128+ * The block's current size in bytes.
129+ *
130+ * new_size ::
131+ * The block's requested new size.
132+ *
133+ * block ::
134+ * The block's current address.
135+ *
136+ * @return:
137+ * New block address. 0~in case of memory shortage.
138+ *
139+ * @note:
140+ * In case of error, the old block must still be available.
141+ *
142+ */
143+ typedef void*
144+ (*FT_Realloc_Func)( FT_Memory memory,
145+ long cur_size,
146+ long new_size,
147+ void* block );
148+
149+
150+ /*************************************************************************
151+ *
152+ * @struct:
153+ * FT_MemoryRec
154+ *
155+ * @description:
156+ * A structure used to describe a given memory manager to FreeType~2.
157+ *
158+ * @fields:
159+ * user ::
160+ * A generic typeless pointer for user data.
161+ *
162+ * alloc ::
163+ * A pointer type to an allocation function.
164+ *
165+ * free ::
166+ * A pointer type to an memory freeing function.
167+ *
168+ * realloc ::
169+ * A pointer type to a reallocation function.
170+ *
171+ */
172+ struct FT_MemoryRec_
173+ {
174+ void* user;
175+ FT_Alloc_Func alloc;
176+ FT_Free_Func free;
177+ FT_Realloc_Func realloc;
178+ };
179+
180+
181+ /*************************************************************************/
182+ /* */
183+ /* I / O M A N A G E M E N T */
184+ /* */
185+ /*************************************************************************/
186+
187+
188+ /*************************************************************************
189+ *
190+ * @type:
191+ * FT_Stream
192+ *
193+ * @description:
194+ * A handle to an input stream.
195+ *
196+ * @also:
197+ * See @FT_StreamRec for the publicly accessible fields of a given
198+ * stream object.
199+ *
200+ */
201+ typedef struct FT_StreamRec_* FT_Stream;
202+
203+
204+ /*************************************************************************
205+ *
206+ * @struct:
207+ * FT_StreamDesc
208+ *
209+ * @description:
210+ * A union type used to store either a long or a pointer. This is used
211+ * to store a file descriptor or a `FILE*' in an input stream.
212+ *
213+ */
214+ typedef union FT_StreamDesc_
215+ {
216+ long value;
217+ void* pointer;
218+
219+ } FT_StreamDesc;
220+
221+
222+ /*************************************************************************
223+ *
224+ * @functype:
225+ * FT_Stream_IoFunc
226+ *
227+ * @description:
228+ * A function used to seek and read data from a given input stream.
229+ *
230+ * @input:
231+ * stream ::
232+ * A handle to the source stream.
233+ *
234+ * offset ::
235+ * The offset of read in stream (always from start).
236+ *
237+ * buffer ::
238+ * The address of the read buffer.
239+ *
240+ * count ::
241+ * The number of bytes to read from the stream.
242+ *
243+ * @return:
244+ * The number of bytes effectively read by the stream.
245+ *
246+ * @note:
247+ * This function might be called to perform a seek or skip operation
248+ * with a `count' of~0. A non-zero return value then indicates an
249+ * error.
250+ *
251+ */
252+ typedef unsigned long
253+ (*FT_Stream_IoFunc)( FT_Stream stream,
254+ unsigned long offset,
255+ unsigned char* buffer,
256+ unsigned long count );
257+
258+
259+ /*************************************************************************
260+ *
261+ * @functype:
262+ * FT_Stream_CloseFunc
263+ *
264+ * @description:
265+ * A function used to close a given input stream.
266+ *
267+ * @input:
268+ * stream ::
269+ * A handle to the target stream.
270+ *
271+ */
272+ typedef void
273+ (*FT_Stream_CloseFunc)( FT_Stream stream );
274+
275+
276+ /*************************************************************************
277+ *
278+ * @struct:
279+ * FT_StreamRec
280+ *
281+ * @description:
282+ * A structure used to describe an input stream.
283+ *
284+ * @input:
285+ * base ::
286+ * For memory-based streams, this is the address of the first stream
287+ * byte in memory. This field should always be set to NULL for
288+ * disk-based streams.
289+ *
290+ * size ::
291+ * The stream size in bytes.
292+ *
293+ * In case of compressed streams where the size is unknown before
294+ * actually doing the decompression, the value is set to 0x7FFFFFFF.
295+ * (Note that this size value can occur for normal streams also; it is
296+ * thus just a hint.)
297+ *
298+ * pos ::
299+ * The current position within the stream.
300+ *
301+ * descriptor ::
302+ * This field is a union that can hold an integer or a pointer. It is
303+ * used by stream implementations to store file descriptors or `FILE*'
304+ * pointers.
305+ *
306+ * pathname ::
307+ * This field is completely ignored by FreeType. However, it is often
308+ * useful during debugging to use it to store the stream's filename
309+ * (where available).
310+ *
311+ * read ::
312+ * The stream's input function.
313+ *
314+ * close ::
315+ * The stream's close function.
316+ *
317+ * memory ::
318+ * The memory manager to use to preload frames. This is set
319+ * internally by FreeType and shouldn't be touched by stream
320+ * implementations.
321+ *
322+ * cursor ::
323+ * This field is set and used internally by FreeType when parsing
324+ * frames.
325+ *
326+ * limit ::
327+ * This field is set and used internally by FreeType when parsing
328+ * frames.
329+ *
330+ */
331+ typedef struct FT_StreamRec_
332+ {
333+ unsigned char* base;
334+ unsigned long size;
335+ unsigned long pos;
336+
337+ FT_StreamDesc descriptor;
338+ FT_StreamDesc pathname;
339+ FT_Stream_IoFunc read;
340+ FT_Stream_CloseFunc close;
341+
342+ FT_Memory memory;
343+ unsigned char* cursor;
344+ unsigned char* limit;
345+
346+ } FT_StreamRec;
347+
348+ /* */
349+
350+
351+FT_END_HEADER
352+
353+#endif /* FTSYSTEM_H_ */
354+
355+
356+/* END */
1@@ -0,0 +1,350 @@
2+/***************************************************************************/
3+/* */
4+/* fttrigon.h */
5+/* */
6+/* FreeType trigonometric functions (specification). */
7+/* */
8+/* Copyright 2001-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTTRIGON_H_
21+#define FTTRIGON_H_
22+
23+#include FT_FREETYPE_H
24+
25+#ifdef FREETYPE_H
26+#error "freetype.h of FreeType 1 has been loaded!"
27+#error "Please fix the directory search order for header files"
28+#error "so that freetype.h of FreeType 2 is found first."
29+#endif
30+
31+
32+FT_BEGIN_HEADER
33+
34+
35+ /*************************************************************************/
36+ /* */
37+ /* <Section> */
38+ /* computations */
39+ /* */
40+ /*************************************************************************/
41+
42+
43+ /*************************************************************************
44+ *
45+ * @type:
46+ * FT_Angle
47+ *
48+ * @description:
49+ * This type is used to model angle values in FreeType. Note that the
50+ * angle is a 16.16 fixed-point value expressed in degrees.
51+ *
52+ */
53+ typedef FT_Fixed FT_Angle;
54+
55+
56+ /*************************************************************************
57+ *
58+ * @macro:
59+ * FT_ANGLE_PI
60+ *
61+ * @description:
62+ * The angle pi expressed in @FT_Angle units.
63+ *
64+ */
65+#define FT_ANGLE_PI ( 180L << 16 )
66+
67+
68+ /*************************************************************************
69+ *
70+ * @macro:
71+ * FT_ANGLE_2PI
72+ *
73+ * @description:
74+ * The angle 2*pi expressed in @FT_Angle units.
75+ *
76+ */
77+#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 )
78+
79+
80+ /*************************************************************************
81+ *
82+ * @macro:
83+ * FT_ANGLE_PI2
84+ *
85+ * @description:
86+ * The angle pi/2 expressed in @FT_Angle units.
87+ *
88+ */
89+#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 )
90+
91+
92+ /*************************************************************************
93+ *
94+ * @macro:
95+ * FT_ANGLE_PI4
96+ *
97+ * @description:
98+ * The angle pi/4 expressed in @FT_Angle units.
99+ *
100+ */
101+#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 )
102+
103+
104+ /*************************************************************************
105+ *
106+ * @function:
107+ * FT_Sin
108+ *
109+ * @description:
110+ * Return the sinus of a given angle in fixed-point format.
111+ *
112+ * @input:
113+ * angle ::
114+ * The input angle.
115+ *
116+ * @return:
117+ * The sinus value.
118+ *
119+ * @note:
120+ * If you need both the sinus and cosinus for a given angle, use the
121+ * function @FT_Vector_Unit.
122+ *
123+ */
124+ FT_EXPORT( FT_Fixed )
125+ FT_Sin( FT_Angle angle );
126+
127+
128+ /*************************************************************************
129+ *
130+ * @function:
131+ * FT_Cos
132+ *
133+ * @description:
134+ * Return the cosinus of a given angle in fixed-point format.
135+ *
136+ * @input:
137+ * angle ::
138+ * The input angle.
139+ *
140+ * @return:
141+ * The cosinus value.
142+ *
143+ * @note:
144+ * If you need both the sinus and cosinus for a given angle, use the
145+ * function @FT_Vector_Unit.
146+ *
147+ */
148+ FT_EXPORT( FT_Fixed )
149+ FT_Cos( FT_Angle angle );
150+
151+
152+ /*************************************************************************
153+ *
154+ * @function:
155+ * FT_Tan
156+ *
157+ * @description:
158+ * Return the tangent of a given angle in fixed-point format.
159+ *
160+ * @input:
161+ * angle ::
162+ * The input angle.
163+ *
164+ * @return:
165+ * The tangent value.
166+ *
167+ */
168+ FT_EXPORT( FT_Fixed )
169+ FT_Tan( FT_Angle angle );
170+
171+
172+ /*************************************************************************
173+ *
174+ * @function:
175+ * FT_Atan2
176+ *
177+ * @description:
178+ * Return the arc-tangent corresponding to a given vector (x,y) in
179+ * the 2d plane.
180+ *
181+ * @input:
182+ * x ::
183+ * The horizontal vector coordinate.
184+ *
185+ * y ::
186+ * The vertical vector coordinate.
187+ *
188+ * @return:
189+ * The arc-tangent value (i.e. angle).
190+ *
191+ */
192+ FT_EXPORT( FT_Angle )
193+ FT_Atan2( FT_Fixed x,
194+ FT_Fixed y );
195+
196+
197+ /*************************************************************************
198+ *
199+ * @function:
200+ * FT_Angle_Diff
201+ *
202+ * @description:
203+ * Return the difference between two angles. The result is always
204+ * constrained to the ]-PI..PI] interval.
205+ *
206+ * @input:
207+ * angle1 ::
208+ * First angle.
209+ *
210+ * angle2 ::
211+ * Second angle.
212+ *
213+ * @return:
214+ * Constrained value of `value2-value1'.
215+ *
216+ */
217+ FT_EXPORT( FT_Angle )
218+ FT_Angle_Diff( FT_Angle angle1,
219+ FT_Angle angle2 );
220+
221+
222+ /*************************************************************************
223+ *
224+ * @function:
225+ * FT_Vector_Unit
226+ *
227+ * @description:
228+ * Return the unit vector corresponding to a given angle. After the
229+ * call, the value of `vec.x' will be `cos(angle)', and the value of
230+ * `vec.y' will be `sin(angle)'.
231+ *
232+ * This function is useful to retrieve both the sinus and cosinus of a
233+ * given angle quickly.
234+ *
235+ * @output:
236+ * vec ::
237+ * The address of target vector.
238+ *
239+ * @input:
240+ * angle ::
241+ * The input angle.
242+ *
243+ */
244+ FT_EXPORT( void )
245+ FT_Vector_Unit( FT_Vector* vec,
246+ FT_Angle angle );
247+
248+
249+ /*************************************************************************
250+ *
251+ * @function:
252+ * FT_Vector_Rotate
253+ *
254+ * @description:
255+ * Rotate a vector by a given angle.
256+ *
257+ * @inout:
258+ * vec ::
259+ * The address of target vector.
260+ *
261+ * @input:
262+ * angle ::
263+ * The input angle.
264+ *
265+ */
266+ FT_EXPORT( void )
267+ FT_Vector_Rotate( FT_Vector* vec,
268+ FT_Angle angle );
269+
270+
271+ /*************************************************************************
272+ *
273+ * @function:
274+ * FT_Vector_Length
275+ *
276+ * @description:
277+ * Return the length of a given vector.
278+ *
279+ * @input:
280+ * vec ::
281+ * The address of target vector.
282+ *
283+ * @return:
284+ * The vector length, expressed in the same units that the original
285+ * vector coordinates.
286+ *
287+ */
288+ FT_EXPORT( FT_Fixed )
289+ FT_Vector_Length( FT_Vector* vec );
290+
291+
292+ /*************************************************************************
293+ *
294+ * @function:
295+ * FT_Vector_Polarize
296+ *
297+ * @description:
298+ * Compute both the length and angle of a given vector.
299+ *
300+ * @input:
301+ * vec ::
302+ * The address of source vector.
303+ *
304+ * @output:
305+ * length ::
306+ * The vector length.
307+ *
308+ * angle ::
309+ * The vector angle.
310+ *
311+ */
312+ FT_EXPORT( void )
313+ FT_Vector_Polarize( FT_Vector* vec,
314+ FT_Fixed *length,
315+ FT_Angle *angle );
316+
317+
318+ /*************************************************************************
319+ *
320+ * @function:
321+ * FT_Vector_From_Polar
322+ *
323+ * @description:
324+ * Compute vector coordinates from a length and angle.
325+ *
326+ * @output:
327+ * vec ::
328+ * The address of source vector.
329+ *
330+ * @input:
331+ * length ::
332+ * The vector length.
333+ *
334+ * angle ::
335+ * The vector angle.
336+ *
337+ */
338+ FT_EXPORT( void )
339+ FT_Vector_From_Polar( FT_Vector* vec,
340+ FT_Fixed length,
341+ FT_Angle angle );
342+
343+ /* */
344+
345+
346+FT_END_HEADER
347+
348+#endif /* FTTRIGON_H_ */
349+
350+
351+/* END */
1@@ -0,0 +1,602 @@
2+/***************************************************************************/
3+/* */
4+/* fttypes.h */
5+/* */
6+/* FreeType simple types definitions (specification only). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTTYPES_H_
21+#define FTTYPES_H_
22+
23+
24+#include <ft2build.h>
25+#include FT_CONFIG_CONFIG_H
26+#include FT_SYSTEM_H
27+#include FT_IMAGE_H
28+
29+#include <stddef.h>
30+
31+
32+FT_BEGIN_HEADER
33+
34+
35+ /*************************************************************************/
36+ /* */
37+ /* <Section> */
38+ /* basic_types */
39+ /* */
40+ /* <Title> */
41+ /* Basic Data Types */
42+ /* */
43+ /* <Abstract> */
44+ /* The basic data types defined by the library. */
45+ /* */
46+ /* <Description> */
47+ /* This section contains the basic data types defined by FreeType~2, */
48+ /* ranging from simple scalar types to bitmap descriptors. More */
49+ /* font-specific structures are defined in a different section. */
50+ /* */
51+ /* <Order> */
52+ /* FT_Byte */
53+ /* FT_Bytes */
54+ /* FT_Char */
55+ /* FT_Int */
56+ /* FT_UInt */
57+ /* FT_Int16 */
58+ /* FT_UInt16 */
59+ /* FT_Int32 */
60+ /* FT_UInt32 */
61+ /* FT_Int64 */
62+ /* FT_UInt64 */
63+ /* FT_Short */
64+ /* FT_UShort */
65+ /* FT_Long */
66+ /* FT_ULong */
67+ /* FT_Bool */
68+ /* FT_Offset */
69+ /* FT_PtrDist */
70+ /* FT_String */
71+ /* FT_Tag */
72+ /* FT_Error */
73+ /* FT_Fixed */
74+ /* FT_Pointer */
75+ /* FT_Pos */
76+ /* FT_Vector */
77+ /* FT_BBox */
78+ /* FT_Matrix */
79+ /* FT_FWord */
80+ /* FT_UFWord */
81+ /* FT_F2Dot14 */
82+ /* FT_UnitVector */
83+ /* FT_F26Dot6 */
84+ /* FT_Data */
85+ /* */
86+ /* FT_MAKE_TAG */
87+ /* */
88+ /* FT_Generic */
89+ /* FT_Generic_Finalizer */
90+ /* */
91+ /* FT_Bitmap */
92+ /* FT_Pixel_Mode */
93+ /* FT_Palette_Mode */
94+ /* FT_Glyph_Format */
95+ /* FT_IMAGE_TAG */
96+ /* */
97+ /*************************************************************************/
98+
99+
100+ /*************************************************************************/
101+ /* */
102+ /* <Type> */
103+ /* FT_Bool */
104+ /* */
105+ /* <Description> */
106+ /* A typedef of unsigned char, used for simple booleans. As usual, */
107+ /* values 1 and~0 represent true and false, respectively. */
108+ /* */
109+ typedef unsigned char FT_Bool;
110+
111+
112+ /*************************************************************************/
113+ /* */
114+ /* <Type> */
115+ /* FT_FWord */
116+ /* */
117+ /* <Description> */
118+ /* A signed 16-bit integer used to store a distance in original font */
119+ /* units. */
120+ /* */
121+ typedef signed short FT_FWord; /* distance in FUnits */
122+
123+
124+ /*************************************************************************/
125+ /* */
126+ /* <Type> */
127+ /* FT_UFWord */
128+ /* */
129+ /* <Description> */
130+ /* An unsigned 16-bit integer used to store a distance in original */
131+ /* font units. */
132+ /* */
133+ typedef unsigned short FT_UFWord; /* unsigned distance */
134+
135+
136+ /*************************************************************************/
137+ /* */
138+ /* <Type> */
139+ /* FT_Char */
140+ /* */
141+ /* <Description> */
142+ /* A simple typedef for the _signed_ char type. */
143+ /* */
144+ typedef signed char FT_Char;
145+
146+
147+ /*************************************************************************/
148+ /* */
149+ /* <Type> */
150+ /* FT_Byte */
151+ /* */
152+ /* <Description> */
153+ /* A simple typedef for the _unsigned_ char type. */
154+ /* */
155+ typedef unsigned char FT_Byte;
156+
157+
158+ /*************************************************************************/
159+ /* */
160+ /* <Type> */
161+ /* FT_Bytes */
162+ /* */
163+ /* <Description> */
164+ /* A typedef for constant memory areas. */
165+ /* */
166+ typedef const FT_Byte* FT_Bytes;
167+
168+
169+ /*************************************************************************/
170+ /* */
171+ /* <Type> */
172+ /* FT_Tag */
173+ /* */
174+ /* <Description> */
175+ /* A typedef for 32-bit tags (as used in the SFNT format). */
176+ /* */
177+ typedef FT_UInt32 FT_Tag;
178+
179+
180+ /*************************************************************************/
181+ /* */
182+ /* <Type> */
183+ /* FT_String */
184+ /* */
185+ /* <Description> */
186+ /* A simple typedef for the char type, usually used for strings. */
187+ /* */
188+ typedef char FT_String;
189+
190+
191+ /*************************************************************************/
192+ /* */
193+ /* <Type> */
194+ /* FT_Short */
195+ /* */
196+ /* <Description> */
197+ /* A typedef for signed short. */
198+ /* */
199+ typedef signed short FT_Short;
200+
201+
202+ /*************************************************************************/
203+ /* */
204+ /* <Type> */
205+ /* FT_UShort */
206+ /* */
207+ /* <Description> */
208+ /* A typedef for unsigned short. */
209+ /* */
210+ typedef unsigned short FT_UShort;
211+
212+
213+ /*************************************************************************/
214+ /* */
215+ /* <Type> */
216+ /* FT_Int */
217+ /* */
218+ /* <Description> */
219+ /* A typedef for the int type. */
220+ /* */
221+ typedef signed int FT_Int;
222+
223+
224+ /*************************************************************************/
225+ /* */
226+ /* <Type> */
227+ /* FT_UInt */
228+ /* */
229+ /* <Description> */
230+ /* A typedef for the unsigned int type. */
231+ /* */
232+ typedef unsigned int FT_UInt;
233+
234+
235+ /*************************************************************************/
236+ /* */
237+ /* <Type> */
238+ /* FT_Long */
239+ /* */
240+ /* <Description> */
241+ /* A typedef for signed long. */
242+ /* */
243+ typedef signed long FT_Long;
244+
245+
246+ /*************************************************************************/
247+ /* */
248+ /* <Type> */
249+ /* FT_ULong */
250+ /* */
251+ /* <Description> */
252+ /* A typedef for unsigned long. */
253+ /* */
254+ typedef unsigned long FT_ULong;
255+
256+
257+ /*************************************************************************/
258+ /* */
259+ /* <Type> */
260+ /* FT_F2Dot14 */
261+ /* */
262+ /* <Description> */
263+ /* A signed 2.14 fixed-point type used for unit vectors. */
264+ /* */
265+ typedef signed short FT_F2Dot14;
266+
267+
268+ /*************************************************************************/
269+ /* */
270+ /* <Type> */
271+ /* FT_F26Dot6 */
272+ /* */
273+ /* <Description> */
274+ /* A signed 26.6 fixed-point type used for vectorial pixel */
275+ /* coordinates. */
276+ /* */
277+ typedef signed long FT_F26Dot6;
278+
279+
280+ /*************************************************************************/
281+ /* */
282+ /* <Type> */
283+ /* FT_Fixed */
284+ /* */
285+ /* <Description> */
286+ /* This type is used to store 16.16 fixed-point values, like scaling */
287+ /* values or matrix coefficients. */
288+ /* */
289+ typedef signed long FT_Fixed;
290+
291+
292+ /*************************************************************************/
293+ /* */
294+ /* <Type> */
295+ /* FT_Error */
296+ /* */
297+ /* <Description> */
298+ /* The FreeType error code type. A value of~0 is always interpreted */
299+ /* as a successful operation. */
300+ /* */
301+ typedef int FT_Error;
302+
303+
304+ /*************************************************************************/
305+ /* */
306+ /* <Type> */
307+ /* FT_Pointer */
308+ /* */
309+ /* <Description> */
310+ /* A simple typedef for a typeless pointer. */
311+ /* */
312+ typedef void* FT_Pointer;
313+
314+
315+ /*************************************************************************/
316+ /* */
317+ /* <Type> */
318+ /* FT_Offset */
319+ /* */
320+ /* <Description> */
321+ /* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */
322+ /* _unsigned_ integer type used to express a file size or position, */
323+ /* or a memory block size. */
324+ /* */
325+ typedef size_t FT_Offset;
326+
327+
328+ /*************************************************************************/
329+ /* */
330+ /* <Type> */
331+ /* FT_PtrDist */
332+ /* */
333+ /* <Description> */
334+ /* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */
335+ /* largest _signed_ integer type used to express the distance */
336+ /* between two pointers. */
337+ /* */
338+ typedef ft_ptrdiff_t FT_PtrDist;
339+
340+
341+ /*************************************************************************/
342+ /* */
343+ /* <Struct> */
344+ /* FT_UnitVector */
345+ /* */
346+ /* <Description> */
347+ /* A simple structure used to store a 2D vector unit vector. Uses */
348+ /* FT_F2Dot14 types. */
349+ /* */
350+ /* <Fields> */
351+ /* x :: Horizontal coordinate. */
352+ /* */
353+ /* y :: Vertical coordinate. */
354+ /* */
355+ typedef struct FT_UnitVector_
356+ {
357+ FT_F2Dot14 x;
358+ FT_F2Dot14 y;
359+
360+ } FT_UnitVector;
361+
362+
363+ /*************************************************************************/
364+ /* */
365+ /* <Struct> */
366+ /* FT_Matrix */
367+ /* */
368+ /* <Description> */
369+ /* A simple structure used to store a 2x2 matrix. Coefficients are */
370+ /* in 16.16 fixed-point format. The computation performed is: */
371+ /* */
372+ /* { */
373+ /* x' = x*xx + y*xy */
374+ /* y' = x*yx + y*yy */
375+ /* } */
376+ /* */
377+ /* <Fields> */
378+ /* xx :: Matrix coefficient. */
379+ /* */
380+ /* xy :: Matrix coefficient. */
381+ /* */
382+ /* yx :: Matrix coefficient. */
383+ /* */
384+ /* yy :: Matrix coefficient. */
385+ /* */
386+ typedef struct FT_Matrix_
387+ {
388+ FT_Fixed xx, xy;
389+ FT_Fixed yx, yy;
390+
391+ } FT_Matrix;
392+
393+
394+ /*************************************************************************/
395+ /* */
396+ /* <Struct> */
397+ /* FT_Data */
398+ /* */
399+ /* <Description> */
400+ /* Read-only binary data represented as a pointer and a length. */
401+ /* */
402+ /* <Fields> */
403+ /* pointer :: The data. */
404+ /* */
405+ /* length :: The length of the data in bytes. */
406+ /* */
407+ typedef struct FT_Data_
408+ {
409+ const FT_Byte* pointer;
410+ FT_Int length;
411+
412+ } FT_Data;
413+
414+
415+ /*************************************************************************/
416+ /* */
417+ /* <FuncType> */
418+ /* FT_Generic_Finalizer */
419+ /* */
420+ /* <Description> */
421+ /* Describe a function used to destroy the `client' data of any */
422+ /* FreeType object. See the description of the @FT_Generic type for */
423+ /* details of usage. */
424+ /* */
425+ /* <Input> */
426+ /* The address of the FreeType object that is under finalization. */
427+ /* Its client data is accessed through its `generic' field. */
428+ /* */
429+ typedef void (*FT_Generic_Finalizer)( void* object );
430+
431+
432+ /*************************************************************************/
433+ /* */
434+ /* <Struct> */
435+ /* FT_Generic */
436+ /* */
437+ /* <Description> */
438+ /* Client applications often need to associate their own data to a */
439+ /* variety of FreeType core objects. For example, a text layout API */
440+ /* might want to associate a glyph cache to a given size object. */
441+ /* */
442+ /* Some FreeType object contains a `generic' field, of type */
443+ /* FT_Generic, which usage is left to client applications and font */
444+ /* servers. */
445+ /* */
446+ /* It can be used to store a pointer to client-specific data, as well */
447+ /* as the address of a `finalizer' function, which will be called by */
448+ /* FreeType when the object is destroyed (for example, the previous */
449+ /* client example would put the address of the glyph cache destructor */
450+ /* in the `finalizer' field). */
451+ /* */
452+ /* <Fields> */
453+ /* data :: A typeless pointer to any client-specified data. This */
454+ /* field is completely ignored by the FreeType library. */
455+ /* */
456+ /* finalizer :: A pointer to a `generic finalizer' function, which */
457+ /* will be called when the object is destroyed. If this */
458+ /* field is set to NULL, no code will be called. */
459+ /* */
460+ typedef struct FT_Generic_
461+ {
462+ void* data;
463+ FT_Generic_Finalizer finalizer;
464+
465+ } FT_Generic;
466+
467+
468+ /*************************************************************************/
469+ /* */
470+ /* <Macro> */
471+ /* FT_MAKE_TAG */
472+ /* */
473+ /* <Description> */
474+ /* This macro converts four-letter tags that are used to label */
475+ /* TrueType tables into an unsigned long, to be used within FreeType. */
476+ /* */
477+ /* <Note> */
478+ /* The produced values *must* be 32-bit integers. Don't redefine */
479+ /* this macro. */
480+ /* */
481+#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
482+ (FT_Tag) \
483+ ( ( (FT_ULong)_x1 << 24 ) | \
484+ ( (FT_ULong)_x2 << 16 ) | \
485+ ( (FT_ULong)_x3 << 8 ) | \
486+ (FT_ULong)_x4 )
487+
488+
489+ /*************************************************************************/
490+ /*************************************************************************/
491+ /* */
492+ /* L I S T M A N A G E M E N T */
493+ /* */
494+ /*************************************************************************/
495+ /*************************************************************************/
496+
497+
498+ /*************************************************************************/
499+ /* */
500+ /* <Section> */
501+ /* list_processing */
502+ /* */
503+ /*************************************************************************/
504+
505+
506+ /*************************************************************************/
507+ /* */
508+ /* <Type> */
509+ /* FT_ListNode */
510+ /* */
511+ /* <Description> */
512+ /* Many elements and objects in FreeType are listed through an */
513+ /* @FT_List record (see @FT_ListRec). As its name suggests, an */
514+ /* FT_ListNode is a handle to a single list element. */
515+ /* */
516+ typedef struct FT_ListNodeRec_* FT_ListNode;
517+
518+
519+ /*************************************************************************/
520+ /* */
521+ /* <Type> */
522+ /* FT_List */
523+ /* */
524+ /* <Description> */
525+ /* A handle to a list record (see @FT_ListRec). */
526+ /* */
527+ typedef struct FT_ListRec_* FT_List;
528+
529+
530+ /*************************************************************************/
531+ /* */
532+ /* <Struct> */
533+ /* FT_ListNodeRec */
534+ /* */
535+ /* <Description> */
536+ /* A structure used to hold a single list element. */
537+ /* */
538+ /* <Fields> */
539+ /* prev :: The previous element in the list. NULL if first. */
540+ /* */
541+ /* next :: The next element in the list. NULL if last. */
542+ /* */
543+ /* data :: A typeless pointer to the listed object. */
544+ /* */
545+ typedef struct FT_ListNodeRec_
546+ {
547+ FT_ListNode prev;
548+ FT_ListNode next;
549+ void* data;
550+
551+ } FT_ListNodeRec;
552+
553+
554+ /*************************************************************************/
555+ /* */
556+ /* <Struct> */
557+ /* FT_ListRec */
558+ /* */
559+ /* <Description> */
560+ /* A structure used to hold a simple doubly-linked list. These are */
561+ /* used in many parts of FreeType. */
562+ /* */
563+ /* <Fields> */
564+ /* head :: The head (first element) of doubly-linked list. */
565+ /* */
566+ /* tail :: The tail (last element) of doubly-linked list. */
567+ /* */
568+ typedef struct FT_ListRec_
569+ {
570+ FT_ListNode head;
571+ FT_ListNode tail;
572+
573+ } FT_ListRec;
574+
575+ /* */
576+
577+
578+#define FT_IS_EMPTY( list ) ( (list).head == 0 )
579+#define FT_BOOL( x ) ( (FT_Bool)( x ) )
580+
581+ /* concatenate C tokens */
582+#define FT_ERR_XCAT( x, y ) x ## y
583+#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
584+
585+ /* see `ftmoderr.h' for descriptions of the following macros */
586+
587+#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
588+
589+#define FT_ERROR_BASE( x ) ( (x) & 0xFF )
590+#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
591+
592+#define FT_ERR_EQ( x, e ) \
593+ ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) )
594+#define FT_ERR_NEQ( x, e ) \
595+ ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) )
596+
597+
598+FT_END_HEADER
599+
600+#endif /* FTTYPES_H_ */
601+
602+
603+/* END */
1@@ -0,0 +1,275 @@
2+/***************************************************************************/
3+/* */
4+/* ftwinfnt.h */
5+/* */
6+/* FreeType API for accessing Windows fnt-specific data. */
7+/* */
8+/* Copyright 2003-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef FTWINFNT_H_
21+#define FTWINFNT_H_
22+
23+#include <ft2build.h>
24+#include FT_FREETYPE_H
25+
26+#ifdef FREETYPE_H
27+#error "freetype.h of FreeType 1 has been loaded!"
28+#error "Please fix the directory search order for header files"
29+#error "so that freetype.h of FreeType 2 is found first."
30+#endif
31+
32+
33+FT_BEGIN_HEADER
34+
35+
36+ /*************************************************************************/
37+ /* */
38+ /* <Section> */
39+ /* winfnt_fonts */
40+ /* */
41+ /* <Title> */
42+ /* Window FNT Files */
43+ /* */
44+ /* <Abstract> */
45+ /* Windows FNT specific API. */
46+ /* */
47+ /* <Description> */
48+ /* This section contains the declaration of Windows FNT specific */
49+ /* functions. */
50+ /* */
51+ /*************************************************************************/
52+
53+
54+ /*************************************************************************
55+ *
56+ * @enum:
57+ * FT_WinFNT_ID_XXX
58+ *
59+ * @description:
60+ * A list of valid values for the `charset' byte in
61+ * @FT_WinFNT_HeaderRec. Exact mapping tables for the various cpXXXX
62+ * encodings (except for cp1361) can be found at
63+ * ftp://ftp.unicode.org/Public in the MAPPINGS/VENDORS/MICSFT/WINDOWS
64+ * subdirectory. cp1361 is roughly a superset of
65+ * MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT.
66+ *
67+ * @values:
68+ * FT_WinFNT_ID_DEFAULT ::
69+ * This is used for font enumeration and font creation as a
70+ * `don't care' value. Valid font files don't contain this value.
71+ * When querying for information about the character set of the font
72+ * that is currently selected into a specified device context, this
73+ * return value (of the related Windows API) simply denotes failure.
74+ *
75+ * FT_WinFNT_ID_SYMBOL ::
76+ * There is no known mapping table available.
77+ *
78+ * FT_WinFNT_ID_MAC ::
79+ * Mac Roman encoding.
80+ *
81+ * FT_WinFNT_ID_OEM ::
82+ * From Michael Poettgen <michael@poettgen.de>:
83+ *
84+ * The `Windows Font Mapping' article says that FT_WinFNT_ID_OEM
85+ * is used for the charset of vector fonts, like `modern.fon',
86+ * `roman.fon', and `script.fon' on Windows.
87+ *
88+ * The `CreateFont' documentation says: The FT_WinFNT_ID_OEM value
89+ * specifies a character set that is operating-system dependent.
90+ *
91+ * The `IFIMETRICS' documentation from the `Windows Driver
92+ * Development Kit' says: This font supports an OEM-specific
93+ * character set. The OEM character set is system dependent.
94+ *
95+ * In general OEM, as opposed to ANSI (i.e., cp1252), denotes the
96+ * second default codepage that most international versions of
97+ * Windows have. It is one of the OEM codepages from
98+ *
99+ * https://msdn.microsoft.com/en-us/goglobal/bb964655,
100+ *
101+ * and is used for the `DOS boxes', to support legacy applications.
102+ * A German Windows version for example usually uses ANSI codepage
103+ * 1252 and OEM codepage 850.
104+ *
105+ * FT_WinFNT_ID_CP874 ::
106+ * A superset of Thai TIS 620 and ISO 8859-11.
107+ *
108+ * FT_WinFNT_ID_CP932 ::
109+ * A superset of Japanese Shift-JIS (with minor deviations).
110+ *
111+ * FT_WinFNT_ID_CP936 ::
112+ * A superset of simplified Chinese GB 2312-1980 (with different
113+ * ordering and minor deviations).
114+ *
115+ * FT_WinFNT_ID_CP949 ::
116+ * A superset of Korean Hangul KS~C 5601-1987 (with different
117+ * ordering and minor deviations).
118+ *
119+ * FT_WinFNT_ID_CP950 ::
120+ * A superset of traditional Chinese Big~5 ETen (with different
121+ * ordering and minor deviations).
122+ *
123+ * FT_WinFNT_ID_CP1250 ::
124+ * A superset of East European ISO 8859-2 (with slightly different
125+ * ordering).
126+ *
127+ * FT_WinFNT_ID_CP1251 ::
128+ * A superset of Russian ISO 8859-5 (with different ordering).
129+ *
130+ * FT_WinFNT_ID_CP1252 ::
131+ * ANSI encoding. A superset of ISO 8859-1.
132+ *
133+ * FT_WinFNT_ID_CP1253 ::
134+ * A superset of Greek ISO 8859-7 (with minor modifications).
135+ *
136+ * FT_WinFNT_ID_CP1254 ::
137+ * A superset of Turkish ISO 8859-9.
138+ *
139+ * FT_WinFNT_ID_CP1255 ::
140+ * A superset of Hebrew ISO 8859-8 (with some modifications).
141+ *
142+ * FT_WinFNT_ID_CP1256 ::
143+ * A superset of Arabic ISO 8859-6 (with different ordering).
144+ *
145+ * FT_WinFNT_ID_CP1257 ::
146+ * A superset of Baltic ISO 8859-13 (with some deviations).
147+ *
148+ * FT_WinFNT_ID_CP1258 ::
149+ * For Vietnamese. This encoding doesn't cover all necessary
150+ * characters.
151+ *
152+ * FT_WinFNT_ID_CP1361 ::
153+ * Korean (Johab).
154+ */
155+
156+#define FT_WinFNT_ID_CP1252 0
157+#define FT_WinFNT_ID_DEFAULT 1
158+#define FT_WinFNT_ID_SYMBOL 2
159+#define FT_WinFNT_ID_MAC 77
160+#define FT_WinFNT_ID_CP932 128
161+#define FT_WinFNT_ID_CP949 129
162+#define FT_WinFNT_ID_CP1361 130
163+#define FT_WinFNT_ID_CP936 134
164+#define FT_WinFNT_ID_CP950 136
165+#define FT_WinFNT_ID_CP1253 161
166+#define FT_WinFNT_ID_CP1254 162
167+#define FT_WinFNT_ID_CP1258 163
168+#define FT_WinFNT_ID_CP1255 177
169+#define FT_WinFNT_ID_CP1256 178
170+#define FT_WinFNT_ID_CP1257 186
171+#define FT_WinFNT_ID_CP1251 204
172+#define FT_WinFNT_ID_CP874 222
173+#define FT_WinFNT_ID_CP1250 238
174+#define FT_WinFNT_ID_OEM 255
175+
176+
177+ /*************************************************************************/
178+ /* */
179+ /* <Struct> */
180+ /* FT_WinFNT_HeaderRec */
181+ /* */
182+ /* <Description> */
183+ /* Windows FNT Header info. */
184+ /* */
185+ typedef struct FT_WinFNT_HeaderRec_
186+ {
187+ FT_UShort version;
188+ FT_ULong file_size;
189+ FT_Byte copyright[60];
190+ FT_UShort file_type;
191+ FT_UShort nominal_point_size;
192+ FT_UShort vertical_resolution;
193+ FT_UShort horizontal_resolution;
194+ FT_UShort ascent;
195+ FT_UShort internal_leading;
196+ FT_UShort external_leading;
197+ FT_Byte italic;
198+ FT_Byte underline;
199+ FT_Byte strike_out;
200+ FT_UShort weight;
201+ FT_Byte charset;
202+ FT_UShort pixel_width;
203+ FT_UShort pixel_height;
204+ FT_Byte pitch_and_family;
205+ FT_UShort avg_width;
206+ FT_UShort max_width;
207+ FT_Byte first_char;
208+ FT_Byte last_char;
209+ FT_Byte default_char;
210+ FT_Byte break_char;
211+ FT_UShort bytes_per_row;
212+ FT_ULong device_offset;
213+ FT_ULong face_name_offset;
214+ FT_ULong bits_pointer;
215+ FT_ULong bits_offset;
216+ FT_Byte reserved;
217+ FT_ULong flags;
218+ FT_UShort A_space;
219+ FT_UShort B_space;
220+ FT_UShort C_space;
221+ FT_UShort color_table_offset;
222+ FT_ULong reserved1[4];
223+
224+ } FT_WinFNT_HeaderRec;
225+
226+
227+ /*************************************************************************/
228+ /* */
229+ /* <Struct> */
230+ /* FT_WinFNT_Header */
231+ /* */
232+ /* <Description> */
233+ /* A handle to an @FT_WinFNT_HeaderRec structure. */
234+ /* */
235+ typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header;
236+
237+
238+ /**********************************************************************
239+ *
240+ * @function:
241+ * FT_Get_WinFNT_Header
242+ *
243+ * @description:
244+ * Retrieve a Windows FNT font info header.
245+ *
246+ * @input:
247+ * face :: A handle to the input face.
248+ *
249+ * @output:
250+ * aheader :: The WinFNT header.
251+ *
252+ * @return:
253+ * FreeType error code. 0~means success.
254+ *
255+ * @note:
256+ * This function only works with Windows FNT faces, returning an error
257+ * otherwise.
258+ */
259+ FT_EXPORT( FT_Error )
260+ FT_Get_WinFNT_Header( FT_Face face,
261+ FT_WinFNT_HeaderRec *aheader );
262+
263+ /* */
264+
265+
266+FT_END_HEADER
267+
268+#endif /* FTWINFNT_H_ */
269+
270+
271+/* END */
272+
273+
274+/* Local Variables: */
275+/* coding: utf-8 */
276+/* End: */
1@@ -0,0 +1,770 @@
2+/***************************************************************************/
3+/* */
4+/* t1tables.h */
5+/* */
6+/* Basic Type 1/Type 2 tables definitions and interface (specification */
7+/* only). */
8+/* */
9+/* Copyright 1996-2018 by */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+
21+#ifndef T1TABLES_H_
22+#define T1TABLES_H_
23+
24+
25+#include <ft2build.h>
26+#include FT_FREETYPE_H
27+
28+#ifdef FREETYPE_H
29+#error "freetype.h of FreeType 1 has been loaded!"
30+#error "Please fix the directory search order for header files"
31+#error "so that freetype.h of FreeType 2 is found first."
32+#endif
33+
34+
35+FT_BEGIN_HEADER
36+
37+
38+ /*************************************************************************/
39+ /* */
40+ /* <Section> */
41+ /* type1_tables */
42+ /* */
43+ /* <Title> */
44+ /* Type 1 Tables */
45+ /* */
46+ /* <Abstract> */
47+ /* Type~1 (PostScript) specific font tables. */
48+ /* */
49+ /* <Description> */
50+ /* This section contains the definition of Type 1-specific tables, */
51+ /* including structures related to other PostScript font formats. */
52+ /* */
53+ /* <Order> */
54+ /* PS_FontInfoRec */
55+ /* PS_FontInfo */
56+ /* PS_PrivateRec */
57+ /* PS_Private */
58+ /* */
59+ /* CID_FaceDictRec */
60+ /* CID_FaceDict */
61+ /* CID_FaceInfoRec */
62+ /* CID_FaceInfo */
63+ /* */
64+ /* FT_Has_PS_Glyph_Names */
65+ /* FT_Get_PS_Font_Info */
66+ /* FT_Get_PS_Font_Private */
67+ /* FT_Get_PS_Font_Value */
68+ /* */
69+ /* T1_Blend_Flags */
70+ /* T1_EncodingType */
71+ /* PS_Dict_Keys */
72+ /* */
73+ /*************************************************************************/
74+
75+
76+ /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */
77+ /* structures in order to support Multiple Master fonts. */
78+
79+
80+ /*************************************************************************/
81+ /* */
82+ /* <Struct> */
83+ /* PS_FontInfoRec */
84+ /* */
85+ /* <Description> */
86+ /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */
87+ /* Note that for Multiple Master fonts, each instance has its own */
88+ /* FontInfo dictionary. */
89+ /* */
90+ typedef struct PS_FontInfoRec_
91+ {
92+ FT_String* version;
93+ FT_String* notice;
94+ FT_String* full_name;
95+ FT_String* family_name;
96+ FT_String* weight;
97+ FT_Long italic_angle;
98+ FT_Bool is_fixed_pitch;
99+ FT_Short underline_position;
100+ FT_UShort underline_thickness;
101+
102+ } PS_FontInfoRec;
103+
104+
105+ /*************************************************************************/
106+ /* */
107+ /* <Struct> */
108+ /* PS_FontInfo */
109+ /* */
110+ /* <Description> */
111+ /* A handle to a @PS_FontInfoRec structure. */
112+ /* */
113+ typedef struct PS_FontInfoRec_* PS_FontInfo;
114+
115+
116+ /*************************************************************************/
117+ /* */
118+ /* <Struct> */
119+ /* T1_FontInfo */
120+ /* */
121+ /* <Description> */
122+ /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */
123+ /* kept to maintain source compatibility between various versions of */
124+ /* FreeType. */
125+ /* */
126+ typedef PS_FontInfoRec T1_FontInfo;
127+
128+
129+ /*************************************************************************/
130+ /* */
131+ /* <Struct> */
132+ /* PS_PrivateRec */
133+ /* */
134+ /* <Description> */
135+ /* A structure used to model a Type~1 or Type~2 private dictionary. */
136+ /* Note that for Multiple Master fonts, each instance has its own */
137+ /* Private dictionary. */
138+ /* */
139+ typedef struct PS_PrivateRec_
140+ {
141+ FT_Int unique_id;
142+ FT_Int lenIV;
143+
144+ FT_Byte num_blue_values;
145+ FT_Byte num_other_blues;
146+ FT_Byte num_family_blues;
147+ FT_Byte num_family_other_blues;
148+
149+ FT_Short blue_values[14];
150+ FT_Short other_blues[10];
151+
152+ FT_Short family_blues [14];
153+ FT_Short family_other_blues[10];
154+
155+ FT_Fixed blue_scale;
156+ FT_Int blue_shift;
157+ FT_Int blue_fuzz;
158+
159+ FT_UShort standard_width[1];
160+ FT_UShort standard_height[1];
161+
162+ FT_Byte num_snap_widths;
163+ FT_Byte num_snap_heights;
164+ FT_Bool force_bold;
165+ FT_Bool round_stem_up;
166+
167+ FT_Short snap_widths [13]; /* including std width */
168+ FT_Short snap_heights[13]; /* including std height */
169+
170+ FT_Fixed expansion_factor;
171+
172+ FT_Long language_group;
173+ FT_Long password;
174+
175+ FT_Short min_feature[2];
176+
177+ } PS_PrivateRec;
178+
179+
180+ /*************************************************************************/
181+ /* */
182+ /* <Struct> */
183+ /* PS_Private */
184+ /* */
185+ /* <Description> */
186+ /* A handle to a @PS_PrivateRec structure. */
187+ /* */
188+ typedef struct PS_PrivateRec_* PS_Private;
189+
190+
191+ /*************************************************************************/
192+ /* */
193+ /* <Struct> */
194+ /* T1_Private */
195+ /* */
196+ /* <Description> */
197+ /* This type is equivalent to @PS_PrivateRec. It is deprecated but */
198+ /* kept to maintain source compatibility between various versions of */
199+ /* FreeType. */
200+ /* */
201+ typedef PS_PrivateRec T1_Private;
202+
203+
204+ /*************************************************************************/
205+ /* */
206+ /* <Enum> */
207+ /* T1_Blend_Flags */
208+ /* */
209+ /* <Description> */
210+ /* A set of flags used to indicate which fields are present in a */
211+ /* given blend dictionary (font info or private). Used to support */
212+ /* Multiple Masters fonts. */
213+ /* */
214+ /* <Values> */
215+ /* T1_BLEND_UNDERLINE_POSITION :: */
216+ /* T1_BLEND_UNDERLINE_THICKNESS :: */
217+ /* T1_BLEND_ITALIC_ANGLE :: */
218+ /* T1_BLEND_BLUE_VALUES :: */
219+ /* T1_BLEND_OTHER_BLUES :: */
220+ /* T1_BLEND_STANDARD_WIDTH :: */
221+ /* T1_BLEND_STANDARD_HEIGHT :: */
222+ /* T1_BLEND_STEM_SNAP_WIDTHS :: */
223+ /* T1_BLEND_STEM_SNAP_HEIGHTS :: */
224+ /* T1_BLEND_BLUE_SCALE :: */
225+ /* T1_BLEND_BLUE_SHIFT :: */
226+ /* T1_BLEND_FAMILY_BLUES :: */
227+ /* T1_BLEND_FAMILY_OTHER_BLUES :: */
228+ /* T1_BLEND_FORCE_BOLD :: */
229+ /* */
230+ typedef enum T1_Blend_Flags_
231+ {
232+ /* required fields in a FontInfo blend dictionary */
233+ T1_BLEND_UNDERLINE_POSITION = 0,
234+ T1_BLEND_UNDERLINE_THICKNESS,
235+ T1_BLEND_ITALIC_ANGLE,
236+
237+ /* required fields in a Private blend dictionary */
238+ T1_BLEND_BLUE_VALUES,
239+ T1_BLEND_OTHER_BLUES,
240+ T1_BLEND_STANDARD_WIDTH,
241+ T1_BLEND_STANDARD_HEIGHT,
242+ T1_BLEND_STEM_SNAP_WIDTHS,
243+ T1_BLEND_STEM_SNAP_HEIGHTS,
244+ T1_BLEND_BLUE_SCALE,
245+ T1_BLEND_BLUE_SHIFT,
246+ T1_BLEND_FAMILY_BLUES,
247+ T1_BLEND_FAMILY_OTHER_BLUES,
248+ T1_BLEND_FORCE_BOLD,
249+
250+ T1_BLEND_MAX /* do not remove */
251+
252+ } T1_Blend_Flags;
253+
254+
255+ /* these constants are deprecated; use the corresponding */
256+ /* `T1_Blend_Flags' values instead */
257+#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION
258+#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS
259+#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE
260+#define t1_blend_blue_values T1_BLEND_BLUE_VALUES
261+#define t1_blend_other_blues T1_BLEND_OTHER_BLUES
262+#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH
263+#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT
264+#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS
265+#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS
266+#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE
267+#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT
268+#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES
269+#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES
270+#define t1_blend_force_bold T1_BLEND_FORCE_BOLD
271+#define t1_blend_max T1_BLEND_MAX
272+
273+ /* */
274+
275+
276+ /* maximum number of Multiple Masters designs, as defined in the spec */
277+#define T1_MAX_MM_DESIGNS 16
278+
279+ /* maximum number of Multiple Masters axes, as defined in the spec */
280+#define T1_MAX_MM_AXIS 4
281+
282+ /* maximum number of elements in a design map */
283+#define T1_MAX_MM_MAP_POINTS 20
284+
285+
286+ /* this structure is used to store the BlendDesignMap entry for an axis */
287+ typedef struct PS_DesignMap_
288+ {
289+ FT_Byte num_points;
290+ FT_Long* design_points;
291+ FT_Fixed* blend_points;
292+
293+ } PS_DesignMapRec, *PS_DesignMap;
294+
295+ /* backward compatible definition */
296+ typedef PS_DesignMapRec T1_DesignMap;
297+
298+
299+ typedef struct PS_BlendRec_
300+ {
301+ FT_UInt num_designs;
302+ FT_UInt num_axis;
303+
304+ FT_String* axis_names[T1_MAX_MM_AXIS];
305+ FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
306+ PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
307+
308+ FT_Fixed* weight_vector;
309+ FT_Fixed* default_weight_vector;
310+
311+ PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
312+ PS_Private privates [T1_MAX_MM_DESIGNS + 1];
313+
314+ FT_ULong blend_bitflags;
315+
316+ FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
317+
318+ /* since 2.3.0 */
319+
320+ /* undocumented, optional: the default design instance; */
321+ /* corresponds to default_weight_vector -- */
322+ /* num_default_design_vector == 0 means it is not present */
323+ /* in the font and associated metrics files */
324+ FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
325+ FT_UInt num_default_design_vector;
326+
327+ } PS_BlendRec, *PS_Blend;
328+
329+
330+ /* backward compatible definition */
331+ typedef PS_BlendRec T1_Blend;
332+
333+
334+ /*************************************************************************/
335+ /* */
336+ /* <Struct> */
337+ /* CID_FaceDictRec */
338+ /* */
339+ /* <Description> */
340+ /* A structure used to represent data in a CID top-level dictionary. */
341+ /* */
342+ typedef struct CID_FaceDictRec_
343+ {
344+ PS_PrivateRec private_dict;
345+
346+ FT_UInt len_buildchar;
347+ FT_Fixed forcebold_threshold;
348+ FT_Pos stroke_width;
349+ FT_Fixed expansion_factor;
350+
351+ FT_Byte paint_type;
352+ FT_Byte font_type;
353+ FT_Matrix font_matrix;
354+ FT_Vector font_offset;
355+
356+ FT_UInt num_subrs;
357+ FT_ULong subrmap_offset;
358+ FT_Int sd_bytes;
359+
360+ } CID_FaceDictRec;
361+
362+
363+ /*************************************************************************/
364+ /* */
365+ /* <Struct> */
366+ /* CID_FaceDict */
367+ /* */
368+ /* <Description> */
369+ /* A handle to a @CID_FaceDictRec structure. */
370+ /* */
371+ typedef struct CID_FaceDictRec_* CID_FaceDict;
372+
373+
374+ /*************************************************************************/
375+ /* */
376+ /* <Struct> */
377+ /* CID_FontDict */
378+ /* */
379+ /* <Description> */
380+ /* This type is equivalent to @CID_FaceDictRec. It is deprecated but */
381+ /* kept to maintain source compatibility between various versions of */
382+ /* FreeType. */
383+ /* */
384+ typedef CID_FaceDictRec CID_FontDict;
385+
386+
387+ /*************************************************************************/
388+ /* */
389+ /* <Struct> */
390+ /* CID_FaceInfoRec */
391+ /* */
392+ /* <Description> */
393+ /* A structure used to represent CID Face information. */
394+ /* */
395+ typedef struct CID_FaceInfoRec_
396+ {
397+ FT_String* cid_font_name;
398+ FT_Fixed cid_version;
399+ FT_Int cid_font_type;
400+
401+ FT_String* registry;
402+ FT_String* ordering;
403+ FT_Int supplement;
404+
405+ PS_FontInfoRec font_info;
406+ FT_BBox font_bbox;
407+ FT_ULong uid_base;
408+
409+ FT_Int num_xuid;
410+ FT_ULong xuid[16];
411+
412+ FT_ULong cidmap_offset;
413+ FT_Int fd_bytes;
414+ FT_Int gd_bytes;
415+ FT_ULong cid_count;
416+
417+ FT_Int num_dicts;
418+ CID_FaceDict font_dicts;
419+
420+ FT_ULong data_offset;
421+
422+ } CID_FaceInfoRec;
423+
424+
425+ /*************************************************************************/
426+ /* */
427+ /* <Struct> */
428+ /* CID_FaceInfo */
429+ /* */
430+ /* <Description> */
431+ /* A handle to a @CID_FaceInfoRec structure. */
432+ /* */
433+ typedef struct CID_FaceInfoRec_* CID_FaceInfo;
434+
435+
436+ /*************************************************************************/
437+ /* */
438+ /* <Struct> */
439+ /* CID_Info */
440+ /* */
441+ /* <Description> */
442+ /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */
443+ /* kept to maintain source compatibility between various versions of */
444+ /* FreeType. */
445+ /* */
446+ typedef CID_FaceInfoRec CID_Info;
447+
448+
449+ /************************************************************************
450+ *
451+ * @function:
452+ * FT_Has_PS_Glyph_Names
453+ *
454+ * @description:
455+ * Return true if a given face provides reliable PostScript glyph
456+ * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro,
457+ * except that certain fonts (mostly TrueType) contain incorrect
458+ * glyph name tables.
459+ *
460+ * When this function returns true, the caller is sure that the glyph
461+ * names returned by @FT_Get_Glyph_Name are reliable.
462+ *
463+ * @input:
464+ * face ::
465+ * face handle
466+ *
467+ * @return:
468+ * Boolean. True if glyph names are reliable.
469+ *
470+ */
471+ FT_EXPORT( FT_Int )
472+ FT_Has_PS_Glyph_Names( FT_Face face );
473+
474+
475+ /************************************************************************
476+ *
477+ * @function:
478+ * FT_Get_PS_Font_Info
479+ *
480+ * @description:
481+ * Retrieve the @PS_FontInfoRec structure corresponding to a given
482+ * PostScript font.
483+ *
484+ * @input:
485+ * face ::
486+ * PostScript face handle.
487+ *
488+ * @output:
489+ * afont_info ::
490+ * Output font info structure pointer.
491+ *
492+ * @return:
493+ * FreeType error code. 0~means success.
494+ *
495+ * @note:
496+ * String pointers within the @PS_FontInfoRec structure are owned by
497+ * the face and don't need to be freed by the caller. Missing entries
498+ * in the font's FontInfo dictionary are represented by NULL pointers.
499+ *
500+ * If the font's format is not PostScript-based, this function will
501+ * return the `FT_Err_Invalid_Argument' error code.
502+ *
503+ */
504+ FT_EXPORT( FT_Error )
505+ FT_Get_PS_Font_Info( FT_Face face,
506+ PS_FontInfo afont_info );
507+
508+
509+ /************************************************************************
510+ *
511+ * @function:
512+ * FT_Get_PS_Font_Private
513+ *
514+ * @description:
515+ * Retrieve the @PS_PrivateRec structure corresponding to a given
516+ * PostScript font.
517+ *
518+ * @input:
519+ * face ::
520+ * PostScript face handle.
521+ *
522+ * @output:
523+ * afont_private ::
524+ * Output private dictionary structure pointer.
525+ *
526+ * @return:
527+ * FreeType error code. 0~means success.
528+ *
529+ * @note:
530+ * The string pointers within the @PS_PrivateRec structure are owned by
531+ * the face and don't need to be freed by the caller.
532+ *
533+ * If the font's format is not PostScript-based, this function returns
534+ * the `FT_Err_Invalid_Argument' error code.
535+ *
536+ */
537+ FT_EXPORT( FT_Error )
538+ FT_Get_PS_Font_Private( FT_Face face,
539+ PS_Private afont_private );
540+
541+
542+ /*************************************************************************/
543+ /* */
544+ /* <Enum> */
545+ /* T1_EncodingType */
546+ /* */
547+ /* <Description> */
548+ /* An enumeration describing the `Encoding' entry in a Type 1 */
549+ /* dictionary. */
550+ /* */
551+ /* <Values> */
552+ /* T1_ENCODING_TYPE_NONE :: */
553+ /* T1_ENCODING_TYPE_ARRAY :: */
554+ /* T1_ENCODING_TYPE_STANDARD :: */
555+ /* T1_ENCODING_TYPE_ISOLATIN1 :: */
556+ /* T1_ENCODING_TYPE_EXPERT :: */
557+ /* */
558+ /* <Since> */
559+ /* 2.4.8 */
560+ /* */
561+ typedef enum T1_EncodingType_
562+ {
563+ T1_ENCODING_TYPE_NONE = 0,
564+ T1_ENCODING_TYPE_ARRAY,
565+ T1_ENCODING_TYPE_STANDARD,
566+ T1_ENCODING_TYPE_ISOLATIN1,
567+ T1_ENCODING_TYPE_EXPERT
568+
569+ } T1_EncodingType;
570+
571+
572+ /*************************************************************************/
573+ /* */
574+ /* <Enum> */
575+ /* PS_Dict_Keys */
576+ /* */
577+ /* <Description> */
578+ /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */
579+ /* the Type~1 dictionary entry to retrieve. */
580+ /* */
581+ /* <Values> */
582+ /* PS_DICT_FONT_TYPE :: */
583+ /* PS_DICT_FONT_MATRIX :: */
584+ /* PS_DICT_FONT_BBOX :: */
585+ /* PS_DICT_PAINT_TYPE :: */
586+ /* PS_DICT_FONT_NAME :: */
587+ /* PS_DICT_UNIQUE_ID :: */
588+ /* PS_DICT_NUM_CHAR_STRINGS :: */
589+ /* PS_DICT_CHAR_STRING_KEY :: */
590+ /* PS_DICT_CHAR_STRING :: */
591+ /* PS_DICT_ENCODING_TYPE :: */
592+ /* PS_DICT_ENCODING_ENTRY :: */
593+ /* PS_DICT_NUM_SUBRS :: */
594+ /* PS_DICT_SUBR :: */
595+ /* PS_DICT_STD_HW :: */
596+ /* PS_DICT_STD_VW :: */
597+ /* PS_DICT_NUM_BLUE_VALUES :: */
598+ /* PS_DICT_BLUE_VALUE :: */
599+ /* PS_DICT_BLUE_FUZZ :: */
600+ /* PS_DICT_NUM_OTHER_BLUES :: */
601+ /* PS_DICT_OTHER_BLUE :: */
602+ /* PS_DICT_NUM_FAMILY_BLUES :: */
603+ /* PS_DICT_FAMILY_BLUE :: */
604+ /* PS_DICT_NUM_FAMILY_OTHER_BLUES :: */
605+ /* PS_DICT_FAMILY_OTHER_BLUE :: */
606+ /* PS_DICT_BLUE_SCALE :: */
607+ /* PS_DICT_BLUE_SHIFT :: */
608+ /* PS_DICT_NUM_STEM_SNAP_H :: */
609+ /* PS_DICT_STEM_SNAP_H :: */
610+ /* PS_DICT_NUM_STEM_SNAP_V :: */
611+ /* PS_DICT_STEM_SNAP_V :: */
612+ /* PS_DICT_FORCE_BOLD :: */
613+ /* PS_DICT_RND_STEM_UP :: */
614+ /* PS_DICT_MIN_FEATURE :: */
615+ /* PS_DICT_LEN_IV :: */
616+ /* PS_DICT_PASSWORD :: */
617+ /* PS_DICT_LANGUAGE_GROUP :: */
618+ /* PS_DICT_VERSION :: */
619+ /* PS_DICT_NOTICE :: */
620+ /* PS_DICT_FULL_NAME :: */
621+ /* PS_DICT_FAMILY_NAME :: */
622+ /* PS_DICT_WEIGHT :: */
623+ /* PS_DICT_IS_FIXED_PITCH :: */
624+ /* PS_DICT_UNDERLINE_POSITION :: */
625+ /* PS_DICT_UNDERLINE_THICKNESS :: */
626+ /* PS_DICT_FS_TYPE :: */
627+ /* PS_DICT_ITALIC_ANGLE :: */
628+ /* */
629+ /* <Since> */
630+ /* 2.4.8 */
631+ /* */
632+ typedef enum PS_Dict_Keys_
633+ {
634+ /* conventionally in the font dictionary */
635+ PS_DICT_FONT_TYPE, /* FT_Byte */
636+ PS_DICT_FONT_MATRIX, /* FT_Fixed */
637+ PS_DICT_FONT_BBOX, /* FT_Fixed */
638+ PS_DICT_PAINT_TYPE, /* FT_Byte */
639+ PS_DICT_FONT_NAME, /* FT_String* */
640+ PS_DICT_UNIQUE_ID, /* FT_Int */
641+ PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */
642+ PS_DICT_CHAR_STRING_KEY, /* FT_String* */
643+ PS_DICT_CHAR_STRING, /* FT_String* */
644+ PS_DICT_ENCODING_TYPE, /* T1_EncodingType */
645+ PS_DICT_ENCODING_ENTRY, /* FT_String* */
646+
647+ /* conventionally in the font Private dictionary */
648+ PS_DICT_NUM_SUBRS, /* FT_Int */
649+ PS_DICT_SUBR, /* FT_String* */
650+ PS_DICT_STD_HW, /* FT_UShort */
651+ PS_DICT_STD_VW, /* FT_UShort */
652+ PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */
653+ PS_DICT_BLUE_VALUE, /* FT_Short */
654+ PS_DICT_BLUE_FUZZ, /* FT_Int */
655+ PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */
656+ PS_DICT_OTHER_BLUE, /* FT_Short */
657+ PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */
658+ PS_DICT_FAMILY_BLUE, /* FT_Short */
659+ PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */
660+ PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */
661+ PS_DICT_BLUE_SCALE, /* FT_Fixed */
662+ PS_DICT_BLUE_SHIFT, /* FT_Int */
663+ PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */
664+ PS_DICT_STEM_SNAP_H, /* FT_Short */
665+ PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */
666+ PS_DICT_STEM_SNAP_V, /* FT_Short */
667+ PS_DICT_FORCE_BOLD, /* FT_Bool */
668+ PS_DICT_RND_STEM_UP, /* FT_Bool */
669+ PS_DICT_MIN_FEATURE, /* FT_Short */
670+ PS_DICT_LEN_IV, /* FT_Int */
671+ PS_DICT_PASSWORD, /* FT_Long */
672+ PS_DICT_LANGUAGE_GROUP, /* FT_Long */
673+
674+ /* conventionally in the font FontInfo dictionary */
675+ PS_DICT_VERSION, /* FT_String* */
676+ PS_DICT_NOTICE, /* FT_String* */
677+ PS_DICT_FULL_NAME, /* FT_String* */
678+ PS_DICT_FAMILY_NAME, /* FT_String* */
679+ PS_DICT_WEIGHT, /* FT_String* */
680+ PS_DICT_IS_FIXED_PITCH, /* FT_Bool */
681+ PS_DICT_UNDERLINE_POSITION, /* FT_Short */
682+ PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */
683+ PS_DICT_FS_TYPE, /* FT_UShort */
684+ PS_DICT_ITALIC_ANGLE, /* FT_Long */
685+
686+ PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
687+
688+ } PS_Dict_Keys;
689+
690+
691+ /************************************************************************
692+ *
693+ * @function:
694+ * FT_Get_PS_Font_Value
695+ *
696+ * @description:
697+ * Retrieve the value for the supplied key from a PostScript font.
698+ *
699+ * @input:
700+ * face ::
701+ * PostScript face handle.
702+ *
703+ * key ::
704+ * An enumeration value representing the dictionary key to retrieve.
705+ *
706+ * idx ::
707+ * For array values, this specifies the index to be returned.
708+ *
709+ * value ::
710+ * A pointer to memory into which to write the value.
711+ *
712+ * valen_len ::
713+ * The size, in bytes, of the memory supplied for the value.
714+ *
715+ * @output:
716+ * value ::
717+ * The value matching the above key, if it exists.
718+ *
719+ * @return:
720+ * The amount of memory (in bytes) required to hold the requested
721+ * value (if it exists, -1 otherwise).
722+ *
723+ * @note:
724+ * The values returned are not pointers into the internal structures of
725+ * the face, but are `fresh' copies, so that the memory containing them
726+ * belongs to the calling application. This also enforces the
727+ * `read-only' nature of these values, i.e., this function cannot be
728+ * used to manipulate the face.
729+ *
730+ * `value' is a void pointer because the values returned can be of
731+ * various types.
732+ *
733+ * If either `value' is NULL or `value_len' is too small, just the
734+ * required memory size for the requested entry is returned.
735+ *
736+ * The `idx' parameter is used, not only to retrieve elements of, for
737+ * example, the FontMatrix or FontBBox, but also to retrieve name keys
738+ * from the CharStrings dictionary, and the charstrings themselves. It
739+ * is ignored for atomic values.
740+ *
741+ * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To
742+ * get the value as in the font stream, you need to divide by
743+ * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale).
744+ *
745+ * IMPORTANT: Only key/value pairs read by the FreeType interpreter can
746+ * be retrieved. So, for example, PostScript procedures such as NP,
747+ * ND, and RD are not available. Arbitrary keys are, obviously, not be
748+ * available either.
749+ *
750+ * If the font's format is not PostScript-based, this function returns
751+ * the `FT_Err_Invalid_Argument' error code.
752+ *
753+ * @since:
754+ * 2.4.8
755+ *
756+ */
757+ FT_EXPORT( FT_Long )
758+ FT_Get_PS_Font_Value( FT_Face face,
759+ PS_Dict_Keys key,
760+ FT_UInt idx,
761+ void *value,
762+ FT_Long value_len );
763+
764+ /* */
765+
766+FT_END_HEADER
767+
768+#endif /* T1TABLES_H_ */
769+
770+
771+/* END */
+1236,
-0
1@@ -0,0 +1,1236 @@
2+/***************************************************************************/
3+/* */
4+/* ttnameid.h */
5+/* */
6+/* TrueType name ID definitions (specification only). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef TTNAMEID_H_
21+#define TTNAMEID_H_
22+
23+
24+#include <ft2build.h>
25+
26+
27+FT_BEGIN_HEADER
28+
29+
30+ /*************************************************************************/
31+ /* */
32+ /* <Section> */
33+ /* truetype_tables */
34+ /* */
35+
36+
37+ /*************************************************************************/
38+ /* */
39+ /* Possible values for the `platform' identifier code in the name */
40+ /* records of an SFNT `name' table. */
41+ /* */
42+ /*************************************************************************/
43+
44+
45+ /***********************************************************************
46+ *
47+ * @enum:
48+ * TT_PLATFORM_XXX
49+ *
50+ * @description:
51+ * A list of valid values for the `platform_id' identifier code in
52+ * @FT_CharMapRec and @FT_SfntName structures.
53+ *
54+ * @values:
55+ * TT_PLATFORM_APPLE_UNICODE ::
56+ * Used by Apple to indicate a Unicode character map and/or name entry.
57+ * See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note
58+ * that name entries in this format are coded as big-endian UCS-2
59+ * character codes _only_.
60+ *
61+ * TT_PLATFORM_MACINTOSH ::
62+ * Used by Apple to indicate a MacOS-specific charmap and/or name entry.
63+ * See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that
64+ * most TrueType fonts contain an Apple roman charmap to be usable on
65+ * MacOS systems (even if they contain a Microsoft charmap as well).
66+ *
67+ * TT_PLATFORM_ISO ::
68+ * This value was used to specify ISO/IEC 10646 charmaps. It is however
69+ * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding
70+ * `encoding_id' values.
71+ *
72+ * TT_PLATFORM_MICROSOFT ::
73+ * Used by Microsoft to indicate Windows-specific charmaps. See
74+ * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values.
75+ * Note that most fonts contain a Unicode charmap using
76+ * (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS).
77+ *
78+ * TT_PLATFORM_CUSTOM ::
79+ * Used to indicate application-specific charmaps.
80+ *
81+ * TT_PLATFORM_ADOBE ::
82+ * This value isn't part of any font format specification, but is used
83+ * by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec
84+ * structure. See @TT_ADOBE_ID_XXX.
85+ */
86+
87+#define TT_PLATFORM_APPLE_UNICODE 0
88+#define TT_PLATFORM_MACINTOSH 1
89+#define TT_PLATFORM_ISO 2 /* deprecated */
90+#define TT_PLATFORM_MICROSOFT 3
91+#define TT_PLATFORM_CUSTOM 4
92+#define TT_PLATFORM_ADOBE 7 /* artificial */
93+
94+
95+ /***********************************************************************
96+ *
97+ * @enum:
98+ * TT_APPLE_ID_XXX
99+ *
100+ * @description:
101+ * A list of valid values for the `encoding_id' for
102+ * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries.
103+ *
104+ * @values:
105+ * TT_APPLE_ID_DEFAULT ::
106+ * Unicode version 1.0.
107+ *
108+ * TT_APPLE_ID_UNICODE_1_1 ::
109+ * Unicode 1.1; specifies Hangul characters starting at U+34xx.
110+ *
111+ * TT_APPLE_ID_ISO_10646 ::
112+ * Deprecated (identical to preceding).
113+ *
114+ * TT_APPLE_ID_UNICODE_2_0 ::
115+ * Unicode 2.0 and beyond (UTF-16 BMP only).
116+ *
117+ * TT_APPLE_ID_UNICODE_32 ::
118+ * Unicode 3.1 and beyond, using UTF-32.
119+ *
120+ * TT_APPLE_ID_VARIANT_SELECTOR ::
121+ * From Adobe, not Apple. Not a normal cmap. Specifies variations
122+ * on a real cmap.
123+ *
124+ * TT_APPLE_ID_FULL_UNICODE ::
125+ * Used for fallback fonts that provide complete Unicode coverage with
126+ * a type~13 cmap.
127+ */
128+
129+#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */
130+#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */
131+#define TT_APPLE_ID_ISO_10646 2 /* deprecated */
132+#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */
133+#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */
134+#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */
135+#define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */
136+
137+
138+ /***********************************************************************
139+ *
140+ * @enum:
141+ * TT_MAC_ID_XXX
142+ *
143+ * @description:
144+ * A list of valid values for the `encoding_id' for
145+ * @TT_PLATFORM_MACINTOSH charmaps and name entries.
146+ */
147+
148+#define TT_MAC_ID_ROMAN 0
149+#define TT_MAC_ID_JAPANESE 1
150+#define TT_MAC_ID_TRADITIONAL_CHINESE 2
151+#define TT_MAC_ID_KOREAN 3
152+#define TT_MAC_ID_ARABIC 4
153+#define TT_MAC_ID_HEBREW 5
154+#define TT_MAC_ID_GREEK 6
155+#define TT_MAC_ID_RUSSIAN 7
156+#define TT_MAC_ID_RSYMBOL 8
157+#define TT_MAC_ID_DEVANAGARI 9
158+#define TT_MAC_ID_GURMUKHI 10
159+#define TT_MAC_ID_GUJARATI 11
160+#define TT_MAC_ID_ORIYA 12
161+#define TT_MAC_ID_BENGALI 13
162+#define TT_MAC_ID_TAMIL 14
163+#define TT_MAC_ID_TELUGU 15
164+#define TT_MAC_ID_KANNADA 16
165+#define TT_MAC_ID_MALAYALAM 17
166+#define TT_MAC_ID_SINHALESE 18
167+#define TT_MAC_ID_BURMESE 19
168+#define TT_MAC_ID_KHMER 20
169+#define TT_MAC_ID_THAI 21
170+#define TT_MAC_ID_LAOTIAN 22
171+#define TT_MAC_ID_GEORGIAN 23
172+#define TT_MAC_ID_ARMENIAN 24
173+#define TT_MAC_ID_MALDIVIAN 25
174+#define TT_MAC_ID_SIMPLIFIED_CHINESE 25
175+#define TT_MAC_ID_TIBETAN 26
176+#define TT_MAC_ID_MONGOLIAN 27
177+#define TT_MAC_ID_GEEZ 28
178+#define TT_MAC_ID_SLAVIC 29
179+#define TT_MAC_ID_VIETNAMESE 30
180+#define TT_MAC_ID_SINDHI 31
181+#define TT_MAC_ID_UNINTERP 32
182+
183+
184+ /***********************************************************************
185+ *
186+ * @enum:
187+ * TT_ISO_ID_XXX
188+ *
189+ * @description:
190+ * A list of valid values for the `encoding_id' for
191+ * @TT_PLATFORM_ISO charmaps and name entries.
192+ *
193+ * Their use is now deprecated.
194+ *
195+ * @values:
196+ * TT_ISO_ID_7BIT_ASCII ::
197+ * ASCII.
198+ * TT_ISO_ID_10646 ::
199+ * ISO/10646.
200+ * TT_ISO_ID_8859_1 ::
201+ * Also known as Latin-1.
202+ */
203+
204+#define TT_ISO_ID_7BIT_ASCII 0
205+#define TT_ISO_ID_10646 1
206+#define TT_ISO_ID_8859_1 2
207+
208+
209+ /***********************************************************************
210+ *
211+ * @enum:
212+ * TT_MS_ID_XXX
213+ *
214+ * @description:
215+ * A list of valid values for the `encoding_id' for
216+ * @TT_PLATFORM_MICROSOFT charmaps and name entries.
217+ *
218+ * @values:
219+ * TT_MS_ID_SYMBOL_CS ::
220+ * Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL.
221+ *
222+ * TT_MS_ID_UNICODE_CS ::
223+ * Microsoft WGL4 charmap, matching Unicode. See
224+ * @FT_ENCODING_UNICODE.
225+ *
226+ * TT_MS_ID_SJIS ::
227+ * Shift JIS Japanese encoding. See @FT_ENCODING_SJIS.
228+ *
229+ * TT_MS_ID_PRC ::
230+ * Chinese encodings as used in the People's Republic of China (PRC).
231+ * This means the encodings GB~2312 and its supersets GBK and
232+ * GB~18030. See @FT_ENCODING_PRC.
233+ *
234+ * TT_MS_ID_BIG_5 ::
235+ * Traditional Chinese as used in Taiwan and Hong Kong. See
236+ * @FT_ENCODING_BIG5.
237+ *
238+ * TT_MS_ID_WANSUNG ::
239+ * Korean Extended Wansung encoding. See @FT_ENCODING_WANSUNG.
240+ *
241+ * TT_MS_ID_JOHAB ::
242+ * Korean Johab encoding. See @FT_ENCODING_JOHAB.
243+ *
244+ * TT_MS_ID_UCS_4 ::
245+ * UCS-4 or UTF-32 charmaps. This has been added to the OpenType
246+ * specification version 1.4 (mid-2001).
247+ */
248+
249+#define TT_MS_ID_SYMBOL_CS 0
250+#define TT_MS_ID_UNICODE_CS 1
251+#define TT_MS_ID_SJIS 2
252+#define TT_MS_ID_PRC 3
253+#define TT_MS_ID_BIG_5 4
254+#define TT_MS_ID_WANSUNG 5
255+#define TT_MS_ID_JOHAB 6
256+#define TT_MS_ID_UCS_4 10
257+
258+ /* this value is deprecated */
259+#define TT_MS_ID_GB2312 TT_MS_ID_PRC
260+
261+
262+ /***********************************************************************
263+ *
264+ * @enum:
265+ * TT_ADOBE_ID_XXX
266+ *
267+ * @description:
268+ * A list of valid values for the `encoding_id' for
269+ * @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension!
270+ *
271+ * @values:
272+ * TT_ADOBE_ID_STANDARD ::
273+ * Adobe standard encoding.
274+ * TT_ADOBE_ID_EXPERT ::
275+ * Adobe expert encoding.
276+ * TT_ADOBE_ID_CUSTOM ::
277+ * Adobe custom encoding.
278+ * TT_ADOBE_ID_LATIN_1 ::
279+ * Adobe Latin~1 encoding.
280+ */
281+
282+#define TT_ADOBE_ID_STANDARD 0
283+#define TT_ADOBE_ID_EXPERT 1
284+#define TT_ADOBE_ID_CUSTOM 2
285+#define TT_ADOBE_ID_LATIN_1 3
286+
287+
288+ /***********************************************************************
289+ *
290+ * @enum:
291+ * TT_MAC_LANGID_XXX
292+ *
293+ * @description:
294+ * Possible values of the language identifier field in the name records
295+ * of the SFNT `name' table if the `platform' identifier code is
296+ * @TT_PLATFORM_MACINTOSH. These values are also used as return values
297+ * for function @FT_Get_CMap_Language_ID.
298+ *
299+ * The canonical source for Apple's IDs is
300+ *
301+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
302+ */
303+
304+#define TT_MAC_LANGID_ENGLISH 0
305+#define TT_MAC_LANGID_FRENCH 1
306+#define TT_MAC_LANGID_GERMAN 2
307+#define TT_MAC_LANGID_ITALIAN 3
308+#define TT_MAC_LANGID_DUTCH 4
309+#define TT_MAC_LANGID_SWEDISH 5
310+#define TT_MAC_LANGID_SPANISH 6
311+#define TT_MAC_LANGID_DANISH 7
312+#define TT_MAC_LANGID_PORTUGUESE 8
313+#define TT_MAC_LANGID_NORWEGIAN 9
314+#define TT_MAC_LANGID_HEBREW 10
315+#define TT_MAC_LANGID_JAPANESE 11
316+#define TT_MAC_LANGID_ARABIC 12
317+#define TT_MAC_LANGID_FINNISH 13
318+#define TT_MAC_LANGID_GREEK 14
319+#define TT_MAC_LANGID_ICELANDIC 15
320+#define TT_MAC_LANGID_MALTESE 16
321+#define TT_MAC_LANGID_TURKISH 17
322+#define TT_MAC_LANGID_CROATIAN 18
323+#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19
324+#define TT_MAC_LANGID_URDU 20
325+#define TT_MAC_LANGID_HINDI 21
326+#define TT_MAC_LANGID_THAI 22
327+#define TT_MAC_LANGID_KOREAN 23
328+#define TT_MAC_LANGID_LITHUANIAN 24
329+#define TT_MAC_LANGID_POLISH 25
330+#define TT_MAC_LANGID_HUNGARIAN 26
331+#define TT_MAC_LANGID_ESTONIAN 27
332+#define TT_MAC_LANGID_LETTISH 28
333+#define TT_MAC_LANGID_SAAMISK 29
334+#define TT_MAC_LANGID_FAEROESE 30
335+#define TT_MAC_LANGID_FARSI 31
336+#define TT_MAC_LANGID_RUSSIAN 32
337+#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33
338+#define TT_MAC_LANGID_FLEMISH 34
339+#define TT_MAC_LANGID_IRISH 35
340+#define TT_MAC_LANGID_ALBANIAN 36
341+#define TT_MAC_LANGID_ROMANIAN 37
342+#define TT_MAC_LANGID_CZECH 38
343+#define TT_MAC_LANGID_SLOVAK 39
344+#define TT_MAC_LANGID_SLOVENIAN 40
345+#define TT_MAC_LANGID_YIDDISH 41
346+#define TT_MAC_LANGID_SERBIAN 42
347+#define TT_MAC_LANGID_MACEDONIAN 43
348+#define TT_MAC_LANGID_BULGARIAN 44
349+#define TT_MAC_LANGID_UKRAINIAN 45
350+#define TT_MAC_LANGID_BYELORUSSIAN 46
351+#define TT_MAC_LANGID_UZBEK 47
352+#define TT_MAC_LANGID_KAZAKH 48
353+#define TT_MAC_LANGID_AZERBAIJANI 49
354+#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49
355+#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50
356+#define TT_MAC_LANGID_ARMENIAN 51
357+#define TT_MAC_LANGID_GEORGIAN 52
358+#define TT_MAC_LANGID_MOLDAVIAN 53
359+#define TT_MAC_LANGID_KIRGHIZ 54
360+#define TT_MAC_LANGID_TAJIKI 55
361+#define TT_MAC_LANGID_TURKMEN 56
362+#define TT_MAC_LANGID_MONGOLIAN 57
363+#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57
364+#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58
365+#define TT_MAC_LANGID_PASHTO 59
366+#define TT_MAC_LANGID_KURDISH 60
367+#define TT_MAC_LANGID_KASHMIRI 61
368+#define TT_MAC_LANGID_SINDHI 62
369+#define TT_MAC_LANGID_TIBETAN 63
370+#define TT_MAC_LANGID_NEPALI 64
371+#define TT_MAC_LANGID_SANSKRIT 65
372+#define TT_MAC_LANGID_MARATHI 66
373+#define TT_MAC_LANGID_BENGALI 67
374+#define TT_MAC_LANGID_ASSAMESE 68
375+#define TT_MAC_LANGID_GUJARATI 69
376+#define TT_MAC_LANGID_PUNJABI 70
377+#define TT_MAC_LANGID_ORIYA 71
378+#define TT_MAC_LANGID_MALAYALAM 72
379+#define TT_MAC_LANGID_KANNADA 73
380+#define TT_MAC_LANGID_TAMIL 74
381+#define TT_MAC_LANGID_TELUGU 75
382+#define TT_MAC_LANGID_SINHALESE 76
383+#define TT_MAC_LANGID_BURMESE 77
384+#define TT_MAC_LANGID_KHMER 78
385+#define TT_MAC_LANGID_LAO 79
386+#define TT_MAC_LANGID_VIETNAMESE 80
387+#define TT_MAC_LANGID_INDONESIAN 81
388+#define TT_MAC_LANGID_TAGALOG 82
389+#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83
390+#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84
391+#define TT_MAC_LANGID_AMHARIC 85
392+#define TT_MAC_LANGID_TIGRINYA 86
393+#define TT_MAC_LANGID_GALLA 87
394+#define TT_MAC_LANGID_SOMALI 88
395+#define TT_MAC_LANGID_SWAHILI 89
396+#define TT_MAC_LANGID_RUANDA 90
397+#define TT_MAC_LANGID_RUNDI 91
398+#define TT_MAC_LANGID_CHEWA 92
399+#define TT_MAC_LANGID_MALAGASY 93
400+#define TT_MAC_LANGID_ESPERANTO 94
401+#define TT_MAC_LANGID_WELSH 128
402+#define TT_MAC_LANGID_BASQUE 129
403+#define TT_MAC_LANGID_CATALAN 130
404+#define TT_MAC_LANGID_LATIN 131
405+#define TT_MAC_LANGID_QUECHUA 132
406+#define TT_MAC_LANGID_GUARANI 133
407+#define TT_MAC_LANGID_AYMARA 134
408+#define TT_MAC_LANGID_TATAR 135
409+#define TT_MAC_LANGID_UIGHUR 136
410+#define TT_MAC_LANGID_DZONGKHA 137
411+#define TT_MAC_LANGID_JAVANESE 138
412+#define TT_MAC_LANGID_SUNDANESE 139
413+
414+ /* The following codes are new as of 2000-03-10 */
415+#define TT_MAC_LANGID_GALICIAN 140
416+#define TT_MAC_LANGID_AFRIKAANS 141
417+#define TT_MAC_LANGID_BRETON 142
418+#define TT_MAC_LANGID_INUKTITUT 143
419+#define TT_MAC_LANGID_SCOTTISH_GAELIC 144
420+#define TT_MAC_LANGID_MANX_GAELIC 145
421+#define TT_MAC_LANGID_IRISH_GAELIC 146
422+#define TT_MAC_LANGID_TONGAN 147
423+#define TT_MAC_LANGID_GREEK_POLYTONIC 148
424+#define TT_MAC_LANGID_GREELANDIC 149
425+#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150
426+
427+
428+ /***********************************************************************
429+ *
430+ * @enum:
431+ * TT_MS_LANGID_XXX
432+ *
433+ * @description:
434+ * Possible values of the language identifier field in the name records
435+ * of the SFNT `name' table if the `platform' identifier code is
436+ * @TT_PLATFORM_MICROSOFT. These values are also used as return values
437+ * for function @FT_Get_CMap_Language_ID.
438+ *
439+ * The canonical source for Microsoft's IDs is
440+ *
441+ * https://www.microsoft.com/globaldev/reference/lcid-all.mspx ,
442+ *
443+ * however, we only provide macros for language identifiers present in
444+ * the OpenType specification: Microsoft has abandoned the concept of
445+ * LCIDs (language code identifiers), and format~1 of the `name' table
446+ * provides a better mechanism for languages not covered here.
447+ *
448+ * More legacy values not listed in the reference can be found in the
449+ * @FT_TRUETYPE_IDS_H header file.
450+ */
451+
452+#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401
453+#define TT_MS_LANGID_ARABIC_IRAQ 0x0801
454+#define TT_MS_LANGID_ARABIC_EGYPT 0x0C01
455+#define TT_MS_LANGID_ARABIC_LIBYA 0x1001
456+#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401
457+#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801
458+#define TT_MS_LANGID_ARABIC_TUNISIA 0x1C01
459+#define TT_MS_LANGID_ARABIC_OMAN 0x2001
460+#define TT_MS_LANGID_ARABIC_YEMEN 0x2401
461+#define TT_MS_LANGID_ARABIC_SYRIA 0x2801
462+#define TT_MS_LANGID_ARABIC_JORDAN 0x2C01
463+#define TT_MS_LANGID_ARABIC_LEBANON 0x3001
464+#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401
465+#define TT_MS_LANGID_ARABIC_UAE 0x3801
466+#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3C01
467+#define TT_MS_LANGID_ARABIC_QATAR 0x4001
468+#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402
469+#define TT_MS_LANGID_CATALAN_CATALAN 0x0403
470+#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404
471+#define TT_MS_LANGID_CHINESE_PRC 0x0804
472+#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0C04
473+#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004
474+#define TT_MS_LANGID_CHINESE_MACAO 0x1404
475+#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405
476+#define TT_MS_LANGID_DANISH_DENMARK 0x0406
477+#define TT_MS_LANGID_GERMAN_GERMANY 0x0407
478+#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807
479+#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0C07
480+#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007
481+#define TT_MS_LANGID_GERMAN_LIECHTENSTEIN 0x1407
482+#define TT_MS_LANGID_GREEK_GREECE 0x0408
483+#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409
484+#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809
485+#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0C09
486+#define TT_MS_LANGID_ENGLISH_CANADA 0x1009
487+#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409
488+#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809
489+#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1C09
490+#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009
491+#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409
492+#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809
493+#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2C09
494+#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009
495+#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409
496+#define TT_MS_LANGID_ENGLISH_INDIA 0x4009
497+#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409
498+#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809
499+#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040A
500+#define TT_MS_LANGID_SPANISH_MEXICO 0x080A
501+#define TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT 0x0C0A
502+#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A
503+#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A
504+#define TT_MS_LANGID_SPANISH_PANAMA 0x180A
505+#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1C0A
506+#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200A
507+#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240A
508+#define TT_MS_LANGID_SPANISH_PERU 0x280A
509+#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2C0A
510+#define TT_MS_LANGID_SPANISH_ECUADOR 0x300A
511+#define TT_MS_LANGID_SPANISH_CHILE 0x340A
512+#define TT_MS_LANGID_SPANISH_URUGUAY 0x380A
513+#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3C0A
514+#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400A
515+#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440A
516+#define TT_MS_LANGID_SPANISH_HONDURAS 0x480A
517+#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4C0A
518+#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500A
519+#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540A
520+#define TT_MS_LANGID_FINNISH_FINLAND 0x040B
521+#define TT_MS_LANGID_FRENCH_FRANCE 0x040C
522+#define TT_MS_LANGID_FRENCH_BELGIUM 0x080C
523+#define TT_MS_LANGID_FRENCH_CANADA 0x0C0C
524+#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100C
525+#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140C
526+#define TT_MS_LANGID_FRENCH_MONACO 0x180C
527+#define TT_MS_LANGID_HEBREW_ISRAEL 0x040D
528+#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040E
529+#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040F
530+#define TT_MS_LANGID_ITALIAN_ITALY 0x0410
531+#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810
532+#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411
533+#define TT_MS_LANGID_KOREAN_KOREA 0x0412
534+#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413
535+#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813
536+#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414
537+#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814
538+#define TT_MS_LANGID_POLISH_POLAND 0x0415
539+#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416
540+#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816
541+#define TT_MS_LANGID_ROMANSH_SWITZERLAND 0x0417
542+#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418
543+#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419
544+#define TT_MS_LANGID_CROATIAN_CROATIA 0x041A
545+#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081A
546+#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0C1A
547+#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101A
548+#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141A
549+#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181A
550+#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x1C1A
551+#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZ_CYRILLIC 0x201A
552+#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B
553+#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C
554+#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D
555+#define TT_MS_LANGID_SWEDISH_FINLAND 0x081D
556+#define TT_MS_LANGID_THAI_THAILAND 0x041E
557+#define TT_MS_LANGID_TURKISH_TURKEY 0x041F
558+#define TT_MS_LANGID_URDU_PAKISTAN 0x0420
559+#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421
560+#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422
561+#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423
562+#define TT_MS_LANGID_SLOVENIAN_SLOVENIA 0x0424
563+#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425
564+#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426
565+#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427
566+#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428
567+#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042A
568+#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042B
569+#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042C
570+#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082C
571+#define TT_MS_LANGID_BASQUE_BASQUE 0x042D
572+#define TT_MS_LANGID_UPPER_SORBIAN_GERMANY 0x042E
573+#define TT_MS_LANGID_LOWER_SORBIAN_GERMANY 0x082E
574+#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042F
575+#define TT_MS_LANGID_SETSWANA_SOUTH_AFRICA 0x0432
576+#define TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA 0x0434
577+#define TT_MS_LANGID_ISIZULU_SOUTH_AFRICA 0x0435
578+#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436
579+#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437
580+#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438
581+#define TT_MS_LANGID_HINDI_INDIA 0x0439
582+#define TT_MS_LANGID_MALTESE_MALTA 0x043A
583+#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043B
584+#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083B
585+#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3B
586+#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103B
587+#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143B
588+#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183B
589+#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3B
590+#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203B
591+#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243B
592+#define TT_MS_LANGID_IRISH_IRELAND 0x083C
593+#define TT_MS_LANGID_MALAY_MALAYSIA 0x043E
594+#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083E
595+#define TT_MS_LANGID_KAZAKH_KAZAKHSTAN 0x043F
596+#define TT_MS_LANGID_KYRGYZ_KYRGYZSTAN /* Cyrillic*/ 0x0440
597+#define TT_MS_LANGID_KISWAHILI_KENYA 0x0441
598+#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442
599+#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443
600+#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843
601+#define TT_MS_LANGID_TATAR_RUSSIA 0x0444
602+#define TT_MS_LANGID_BENGALI_INDIA 0x0445
603+#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845
604+#define TT_MS_LANGID_PUNJABI_INDIA 0x0446
605+#define TT_MS_LANGID_GUJARATI_INDIA 0x0447
606+#define TT_MS_LANGID_ODIA_INDIA 0x0448
607+#define TT_MS_LANGID_TAMIL_INDIA 0x0449
608+#define TT_MS_LANGID_TELUGU_INDIA 0x044A
609+#define TT_MS_LANGID_KANNADA_INDIA 0x044B
610+#define TT_MS_LANGID_MALAYALAM_INDIA 0x044C
611+#define TT_MS_LANGID_ASSAMESE_INDIA 0x044D
612+#define TT_MS_LANGID_MARATHI_INDIA 0x044E
613+#define TT_MS_LANGID_SANSKRIT_INDIA 0x044F
614+#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450
615+#define TT_MS_LANGID_MONGOLIAN_PRC 0x0850
616+#define TT_MS_LANGID_TIBETAN_PRC 0x0451
617+#define TT_MS_LANGID_WELSH_UNITED_KINGDOM 0x0452
618+#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453
619+#define TT_MS_LANGID_LAO_LAOS 0x0454
620+#define TT_MS_LANGID_GALICIAN_GALICIAN 0x0456
621+#define TT_MS_LANGID_KONKANI_INDIA 0x0457
622+#define TT_MS_LANGID_SYRIAC_SYRIA 0x045A
623+#define TT_MS_LANGID_SINHALA_SRI_LANKA 0x045B
624+#define TT_MS_LANGID_INUKTITUT_CANADA 0x045D
625+#define TT_MS_LANGID_INUKTITUT_CANADA_LATIN 0x085D
626+#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045E
627+#define TT_MS_LANGID_TAMAZIGHT_ALGERIA 0x085F
628+#define TT_MS_LANGID_NEPALI_NEPAL 0x0461
629+#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462
630+#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463
631+#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464
632+#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465
633+#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468
634+#define TT_MS_LANGID_YORUBA_NIGERIA 0x046A
635+#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046B
636+#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086B
637+#define TT_MS_LANGID_QUECHUA_PERU 0x0C6B
638+#define TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA 0x046C
639+#define TT_MS_LANGID_BASHKIR_RUSSIA 0x046D
640+#define TT_MS_LANGID_LUXEMBOURGISH_LUXEMBOURG 0x046E
641+#define TT_MS_LANGID_GREENLANDIC_GREENLAND 0x046F
642+#define TT_MS_LANGID_IGBO_NIGERIA 0x0470
643+#define TT_MS_LANGID_YI_PRC 0x0478
644+#define TT_MS_LANGID_MAPUDUNGUN_CHILE 0x047A
645+#define TT_MS_LANGID_MOHAWK_MOHAWK 0x047C
646+#define TT_MS_LANGID_BRETON_FRANCE 0x047E
647+#define TT_MS_LANGID_UIGHUR_PRC 0x0480
648+#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481
649+#define TT_MS_LANGID_OCCITAN_FRANCE 0x0482
650+#define TT_MS_LANGID_CORSICAN_FRANCE 0x0483
651+#define TT_MS_LANGID_ALSATIAN_FRANCE 0x0484
652+#define TT_MS_LANGID_YAKUT_RUSSIA 0x0485
653+#define TT_MS_LANGID_KICHE_GUATEMALA 0x0486
654+#define TT_MS_LANGID_KINYARWANDA_RWANDA 0x0487
655+#define TT_MS_LANGID_WOLOF_SENEGAL 0x0488
656+#define TT_MS_LANGID_DARI_AFGHANISTAN 0x048C
657+
658+ /* */
659+
660+
661+ /* legacy macro definitions not present in OpenType 1.8.1 */
662+#define TT_MS_LANGID_ARABIC_GENERAL 0x0001
663+#define TT_MS_LANGID_CATALAN_SPAIN \
664+ TT_MS_LANGID_CATALAN_CATALAN
665+#define TT_MS_LANGID_CHINESE_GENERAL 0x0004
666+#define TT_MS_LANGID_CHINESE_MACAU \
667+ TT_MS_LANGID_CHINESE_MACAO
668+#define TT_MS_LANGID_GERMAN_LIECHTENSTEI \
669+ TT_MS_LANGID_GERMAN_LIECHTENSTEIN
670+#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009
671+#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809
672+#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09
673+#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT \
674+ TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT
675+#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU
676+#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1C0C
677+#define TT_MS_LANGID_FRENCH_REUNION 0x200C
678+#define TT_MS_LANGID_FRENCH_CONGO 0x240C
679+ /* which was formerly: */
680+#define TT_MS_LANGID_FRENCH_ZAIRE \
681+ TT_MS_LANGID_FRENCH_CONGO
682+#define TT_MS_LANGID_FRENCH_SENEGAL 0x280C
683+#define TT_MS_LANGID_FRENCH_CAMEROON 0x2C0C
684+#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300C
685+#define TT_MS_LANGID_FRENCH_MALI 0x340C
686+#define TT_MS_LANGID_FRENCH_MOROCCO 0x380C
687+#define TT_MS_LANGID_FRENCH_HAITI 0x3C0C
688+#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU
689+#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA \
690+ TT_MS_LANGID_KOREAN_KOREA
691+#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812
692+#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND \
693+ TT_MS_LANGID_ROMANSH_SWITZERLAND
694+#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818
695+#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819
696+#define TT_MS_LANGID_URDU_INDIA 0x0820
697+#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827
698+#define TT_MS_LANGID_SLOVENE_SLOVENIA \
699+ TT_MS_LANGID_SLOVENIAN_SLOVENIA
700+#define TT_MS_LANGID_FARSI_IRAN 0x0429
701+#define TT_MS_LANGID_BASQUE_SPAIN \
702+ TT_MS_LANGID_BASQUE_BASQUE
703+#define TT_MS_LANGID_SORBIAN_GERMANY \
704+ TT_MS_LANGID_UPPER_SORBIAN_GERMANY
705+#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430
706+#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431
707+#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA \
708+ TT_MS_LANGID_SETSWANA_SOUTH_AFRICA
709+#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433
710+#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA \
711+ TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA
712+#define TT_MS_LANGID_ZULU_SOUTH_AFRICA \
713+ TT_MS_LANGID_ISIZULU_SOUTH_AFRICA
714+#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B
715+ /* the next two values are incorrectly inverted */
716+#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C
717+#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C
718+#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D
719+#define TT_MS_LANGID_KAZAK_KAZAKSTAN \
720+ TT_MS_LANGID_KAZAKH_KAZAKHSTAN
721+#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \
722+ TT_MS_LANGID_KYRGYZ_KYRGYZSTAN
723+#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN \
724+ TT_MS_LANGID_KYRGYZ_KYRGYZSTAN
725+#define TT_MS_LANGID_SWAHILI_KENYA \
726+ TT_MS_LANGID_KISWAHILI_KENYA
727+#define TT_MS_LANGID_TATAR_TATARSTAN \
728+ TT_MS_LANGID_TATAR_RUSSIA
729+#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846
730+#define TT_MS_LANGID_ORIYA_INDIA \
731+ TT_MS_LANGID_ODIA_INDIA
732+#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN \
733+ TT_MS_LANGID_MONGOLIAN_PRC
734+#define TT_MS_LANGID_TIBETAN_CHINA \
735+ TT_MS_LANGID_TIBETAN_PRC
736+#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851
737+#define TT_MS_LANGID_TIBETAN_BHUTAN \
738+ TT_MS_LANGID_DZONGHKA_BHUTAN
739+#define TT_MS_LANGID_WELSH_WALES \
740+ TT_MS_LANGID_WELSH_UNITED_KINGDOM
741+#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455
742+#define TT_MS_LANGID_GALICIAN_SPAIN \
743+ TT_MS_LANGID_GALICIAN_GALICIAN
744+#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458
745+#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459
746+#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859
747+#define TT_MS_LANGID_SINHALESE_SRI_LANKA \
748+ TT_MS_LANGID_SINHALA_SRI_LANKA
749+#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C
750+#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F
751+#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN \
752+ TT_MS_LANGID_TAMAZIGHT_ALGERIA
753+#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460
754+#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860
755+#define TT_MS_LANGID_KASHMIRI_INDIA \
756+ TT_MS_LANGID_KASHMIRI_SASIA
757+#define TT_MS_LANGID_NEPALI_INDIA 0x0861
758+#define TT_MS_LANGID_DIVEHI_MALDIVES \
759+ TT_MS_LANGID_DHIVEHI_MALDIVES
760+#define TT_MS_LANGID_EDO_NIGERIA 0x0466
761+#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467
762+#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469
763+#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA \
764+ TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA
765+#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \
766+ TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA
767+#define TT_MS_LANGID_KANURI_NIGERIA 0x0471
768+#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472
769+#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473
770+#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873
771+#define TT_MS_LANGID_TIGRIGNA_ERYTREA \
772+ TT_MS_LANGID_TIGRIGNA_ERYTHREA
773+#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474
774+#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475
775+#define TT_MS_LANGID_LATIN 0x0476
776+#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477
777+#define TT_MS_LANGID_YI_CHINA \
778+ TT_MS_LANGID_YI_PRC
779+#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479
780+#define TT_MS_LANGID_UIGHUR_CHINA \
781+ TT_MS_LANGID_UIGHUR_PRC
782+
783+
784+ /***********************************************************************
785+ *
786+ * @enum:
787+ * TT_NAME_ID_XXX
788+ *
789+ * @description:
790+ * Possible values of the `name' identifier field in the name records of
791+ * an SFNT `name' table. These values are platform independent.
792+ */
793+
794+#define TT_NAME_ID_COPYRIGHT 0
795+#define TT_NAME_ID_FONT_FAMILY 1
796+#define TT_NAME_ID_FONT_SUBFAMILY 2
797+#define TT_NAME_ID_UNIQUE_ID 3
798+#define TT_NAME_ID_FULL_NAME 4
799+#define TT_NAME_ID_VERSION_STRING 5
800+#define TT_NAME_ID_PS_NAME 6
801+#define TT_NAME_ID_TRADEMARK 7
802+
803+ /* the following values are from the OpenType spec */
804+#define TT_NAME_ID_MANUFACTURER 8
805+#define TT_NAME_ID_DESIGNER 9
806+#define TT_NAME_ID_DESCRIPTION 10
807+#define TT_NAME_ID_VENDOR_URL 11
808+#define TT_NAME_ID_DESIGNER_URL 12
809+#define TT_NAME_ID_LICENSE 13
810+#define TT_NAME_ID_LICENSE_URL 14
811+ /* number 15 is reserved */
812+#define TT_NAME_ID_TYPOGRAPHIC_FAMILY 16
813+#define TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY 17
814+#define TT_NAME_ID_MAC_FULL_NAME 18
815+
816+ /* The following code is new as of 2000-01-21 */
817+#define TT_NAME_ID_SAMPLE_TEXT 19
818+
819+ /* This is new in OpenType 1.3 */
820+#define TT_NAME_ID_CID_FINDFONT_NAME 20
821+
822+ /* This is new in OpenType 1.5 */
823+#define TT_NAME_ID_WWS_FAMILY 21
824+#define TT_NAME_ID_WWS_SUBFAMILY 22
825+
826+ /* This is new in OpenType 1.7 */
827+#define TT_NAME_ID_LIGHT_BACKGROUND 23
828+#define TT_NAME_ID_DARK_BACKGROUND 24
829+
830+ /* This is new in OpenType 1.8 */
831+#define TT_NAME_ID_VARIATIONS_PREFIX 25
832+
833+ /* these two values are deprecated */
834+#define TT_NAME_ID_PREFERRED_FAMILY TT_NAME_ID_TYPOGRAPHIC_FAMILY
835+#define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY
836+
837+
838+ /***********************************************************************
839+ *
840+ * @enum:
841+ * TT_UCR_XXX
842+ *
843+ * @description:
844+ * Possible bit mask values for the `ulUnicodeRangeX' fields in an SFNT
845+ * `OS/2' table.
846+ */
847+
848+ /* ulUnicodeRange1 */
849+ /* --------------- */
850+
851+ /* Bit 0 Basic Latin */
852+#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */
853+ /* Bit 1 C1 Controls and Latin-1 Supplement */
854+#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */
855+ /* Bit 2 Latin Extended-A */
856+#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */
857+ /* Bit 3 Latin Extended-B */
858+#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */
859+ /* Bit 4 IPA Extensions */
860+ /* Phonetic Extensions */
861+ /* Phonetic Extensions Supplement */
862+#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */
863+ /* U+1D00-U+1D7F */
864+ /* U+1D80-U+1DBF */
865+ /* Bit 5 Spacing Modifier Letters */
866+ /* Modifier Tone Letters */
867+#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */
868+ /* U+A700-U+A71F */
869+ /* Bit 6 Combining Diacritical Marks */
870+ /* Combining Diacritical Marks Supplement */
871+#define TT_UCR_COMBINING_DIACRITICAL_MARKS (1L << 6) /* U+0300-U+036F */
872+ /* U+1DC0-U+1DFF */
873+ /* Bit 7 Greek and Coptic */
874+#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */
875+ /* Bit 8 Coptic */
876+#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */
877+ /* Bit 9 Cyrillic */
878+ /* Cyrillic Supplement */
879+ /* Cyrillic Extended-A */
880+ /* Cyrillic Extended-B */
881+#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */
882+ /* U+0500-U+052F */
883+ /* U+2DE0-U+2DFF */
884+ /* U+A640-U+A69F */
885+ /* Bit 10 Armenian */
886+#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */
887+ /* Bit 11 Hebrew */
888+#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */
889+ /* Bit 12 Vai */
890+#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */
891+ /* Bit 13 Arabic */
892+ /* Arabic Supplement */
893+#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */
894+ /* U+0750-U+077F */
895+ /* Bit 14 NKo */
896+#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */
897+ /* Bit 15 Devanagari */
898+#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */
899+ /* Bit 16 Bengali */
900+#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */
901+ /* Bit 17 Gurmukhi */
902+#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */
903+ /* Bit 18 Gujarati */
904+#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */
905+ /* Bit 19 Oriya */
906+#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */
907+ /* Bit 20 Tamil */
908+#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */
909+ /* Bit 21 Telugu */
910+#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */
911+ /* Bit 22 Kannada */
912+#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */
913+ /* Bit 23 Malayalam */
914+#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */
915+ /* Bit 24 Thai */
916+#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */
917+ /* Bit 25 Lao */
918+#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */
919+ /* Bit 26 Georgian */
920+ /* Georgian Supplement */
921+#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */
922+ /* U+2D00-U+2D2F */
923+ /* Bit 27 Balinese */
924+#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */
925+ /* Bit 28 Hangul Jamo */
926+#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */
927+ /* Bit 29 Latin Extended Additional */
928+ /* Latin Extended-C */
929+ /* Latin Extended-D */
930+#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */
931+ /* U+2C60-U+2C7F */
932+ /* U+A720-U+A7FF */
933+ /* Bit 30 Greek Extended */
934+#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */
935+ /* Bit 31 General Punctuation */
936+ /* Supplemental Punctuation */
937+#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */
938+ /* U+2E00-U+2E7F */
939+
940+ /* ulUnicodeRange2 */
941+ /* --------------- */
942+
943+ /* Bit 32 Superscripts And Subscripts */
944+#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */
945+ /* Bit 33 Currency Symbols */
946+#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */
947+ /* Bit 34 Combining Diacritical Marks For Symbols */
948+#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \
949+ (1L << 2) /* U+20D0-U+20FF */
950+ /* Bit 35 Letterlike Symbols */
951+#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */
952+ /* Bit 36 Number Forms */
953+#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */
954+ /* Bit 37 Arrows */
955+ /* Supplemental Arrows-A */
956+ /* Supplemental Arrows-B */
957+ /* Miscellaneous Symbols and Arrows */
958+#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */
959+ /* U+27F0-U+27FF */
960+ /* U+2900-U+297F */
961+ /* U+2B00-U+2BFF */
962+ /* Bit 38 Mathematical Operators */
963+ /* Supplemental Mathematical Operators */
964+ /* Miscellaneous Mathematical Symbols-A */
965+ /* Miscellaneous Mathematical Symbols-B */
966+#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */
967+ /* U+2A00-U+2AFF */
968+ /* U+27C0-U+27EF */
969+ /* U+2980-U+29FF */
970+ /* Bit 39 Miscellaneous Technical */
971+#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */
972+ /* Bit 40 Control Pictures */
973+#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */
974+ /* Bit 41 Optical Character Recognition */
975+#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */
976+ /* Bit 42 Enclosed Alphanumerics */
977+#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */
978+ /* Bit 43 Box Drawing */
979+#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */
980+ /* Bit 44 Block Elements */
981+#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */
982+ /* Bit 45 Geometric Shapes */
983+#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */
984+ /* Bit 46 Miscellaneous Symbols */
985+#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */
986+ /* Bit 47 Dingbats */
987+#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */
988+ /* Bit 48 CJK Symbols and Punctuation */
989+#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */
990+ /* Bit 49 Hiragana */
991+#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */
992+ /* Bit 50 Katakana */
993+ /* Katakana Phonetic Extensions */
994+#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */
995+ /* U+31F0-U+31FF */
996+ /* Bit 51 Bopomofo */
997+ /* Bopomofo Extended */
998+#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */
999+ /* U+31A0-U+31BF */
1000+ /* Bit 52 Hangul Compatibility Jamo */
1001+#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */
1002+ /* Bit 53 Phags-Pa */
1003+#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */
1004+#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */
1005+#define TT_UCR_PHAGSPA
1006+ /* Bit 54 Enclosed CJK Letters and Months */
1007+#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */
1008+ /* Bit 55 CJK Compatibility */
1009+#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */
1010+ /* Bit 56 Hangul Syllables */
1011+#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */
1012+ /* Bit 57 High Surrogates */
1013+ /* High Private Use Surrogates */
1014+ /* Low Surrogates */
1015+
1016+ /* According to OpenType specs v.1.3+, */
1017+ /* setting bit 57 implies that there is */
1018+ /* at least one codepoint beyond the */
1019+ /* Basic Multilingual Plane that is */
1020+ /* supported by this font. So it really */
1021+ /* means >= U+10000. */
1022+#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */
1023+ /* U+DB80-U+DBFF */
1024+ /* U+DC00-U+DFFF */
1025+#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES
1026+ /* Bit 58 Phoenician */
1027+#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/
1028+ /* Bit 59 CJK Unified Ideographs */
1029+ /* CJK Radicals Supplement */
1030+ /* Kangxi Radicals */
1031+ /* Ideographic Description Characters */
1032+ /* CJK Unified Ideographs Extension A */
1033+ /* CJK Unified Ideographs Extension B */
1034+ /* Kanbun */
1035+#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */
1036+ /* U+2E80-U+2EFF */
1037+ /* U+2F00-U+2FDF */
1038+ /* U+2FF0-U+2FFF */
1039+ /* U+3400-U+4DB5 */
1040+ /*U+20000-U+2A6DF*/
1041+ /* U+3190-U+319F */
1042+ /* Bit 60 Private Use */
1043+#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */
1044+ /* Bit 61 CJK Strokes */
1045+ /* CJK Compatibility Ideographs */
1046+ /* CJK Compatibility Ideographs Supplement */
1047+#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */
1048+ /* U+F900-U+FAFF */
1049+ /*U+2F800-U+2FA1F*/
1050+ /* Bit 62 Alphabetic Presentation Forms */
1051+#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */
1052+ /* Bit 63 Arabic Presentation Forms-A */
1053+#define TT_UCR_ARABIC_PRESENTATION_FORMS_A (1L << 31) /* U+FB50-U+FDFF */
1054+
1055+ /* ulUnicodeRange3 */
1056+ /* --------------- */
1057+
1058+ /* Bit 64 Combining Half Marks */
1059+#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */
1060+ /* Bit 65 Vertical forms */
1061+ /* CJK Compatibility Forms */
1062+#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */
1063+ /* U+FE30-U+FE4F */
1064+ /* Bit 66 Small Form Variants */
1065+#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */
1066+ /* Bit 67 Arabic Presentation Forms-B */
1067+#define TT_UCR_ARABIC_PRESENTATION_FORMS_B (1L << 3) /* U+FE70-U+FEFE */
1068+ /* Bit 68 Halfwidth and Fullwidth Forms */
1069+#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */
1070+ /* Bit 69 Specials */
1071+#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */
1072+ /* Bit 70 Tibetan */
1073+#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */
1074+ /* Bit 71 Syriac */
1075+#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */
1076+ /* Bit 72 Thaana */
1077+#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */
1078+ /* Bit 73 Sinhala */
1079+#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */
1080+ /* Bit 74 Myanmar */
1081+#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */
1082+ /* Bit 75 Ethiopic */
1083+ /* Ethiopic Supplement */
1084+ /* Ethiopic Extended */
1085+#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */
1086+ /* U+1380-U+139F */
1087+ /* U+2D80-U+2DDF */
1088+ /* Bit 76 Cherokee */
1089+#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */
1090+ /* Bit 77 Unified Canadian Aboriginal Syllabics */
1091+#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */
1092+ /* Bit 78 Ogham */
1093+#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */
1094+ /* Bit 79 Runic */
1095+#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */
1096+ /* Bit 80 Khmer */
1097+ /* Khmer Symbols */
1098+#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */
1099+ /* U+19E0-U+19FF */
1100+ /* Bit 81 Mongolian */
1101+#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */
1102+ /* Bit 82 Braille Patterns */
1103+#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */
1104+ /* Bit 83 Yi Syllables */
1105+ /* Yi Radicals */
1106+#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */
1107+ /* U+A490-U+A4CF */
1108+ /* Bit 84 Tagalog */
1109+ /* Hanunoo */
1110+ /* Buhid */
1111+ /* Tagbanwa */
1112+#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */
1113+ /* U+1720-U+173F */
1114+ /* U+1740-U+175F */
1115+ /* U+1760-U+177F */
1116+ /* Bit 85 Old Italic */
1117+#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/
1118+ /* Bit 86 Gothic */
1119+#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/
1120+ /* Bit 87 Deseret */
1121+#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/
1122+ /* Bit 88 Byzantine Musical Symbols */
1123+ /* Musical Symbols */
1124+ /* Ancient Greek Musical Notation */
1125+#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/
1126+ /*U+1D100-U+1D1FF*/
1127+ /*U+1D200-U+1D24F*/
1128+ /* Bit 89 Mathematical Alphanumeric Symbols */
1129+#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/
1130+ /* Bit 90 Private Use (plane 15) */
1131+ /* Private Use (plane 16) */
1132+#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/
1133+ /*U+100000-U+10FFFD*/
1134+ /* Bit 91 Variation Selectors */
1135+ /* Variation Selectors Supplement */
1136+#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */
1137+ /*U+E0100-U+E01EF*/
1138+ /* Bit 92 Tags */
1139+#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/
1140+ /* Bit 93 Limbu */
1141+#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */
1142+ /* Bit 94 Tai Le */
1143+#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */
1144+ /* Bit 95 New Tai Lue */
1145+#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */
1146+
1147+ /* ulUnicodeRange4 */
1148+ /* --------------- */
1149+
1150+ /* Bit 96 Buginese */
1151+#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */
1152+ /* Bit 97 Glagolitic */
1153+#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */
1154+ /* Bit 98 Tifinagh */
1155+#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */
1156+ /* Bit 99 Yijing Hexagram Symbols */
1157+#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */
1158+ /* Bit 100 Syloti Nagri */
1159+#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */
1160+ /* Bit 101 Linear B Syllabary */
1161+ /* Linear B Ideograms */
1162+ /* Aegean Numbers */
1163+#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/
1164+ /*U+10080-U+100FF*/
1165+ /*U+10100-U+1013F*/
1166+ /* Bit 102 Ancient Greek Numbers */
1167+#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/
1168+ /* Bit 103 Ugaritic */
1169+#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/
1170+ /* Bit 104 Old Persian */
1171+#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/
1172+ /* Bit 105 Shavian */
1173+#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/
1174+ /* Bit 106 Osmanya */
1175+#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/
1176+ /* Bit 107 Cypriot Syllabary */
1177+#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/
1178+ /* Bit 108 Kharoshthi */
1179+#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/
1180+ /* Bit 109 Tai Xuan Jing Symbols */
1181+#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/
1182+ /* Bit 110 Cuneiform */
1183+ /* Cuneiform Numbers and Punctuation */
1184+#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/
1185+ /*U+12400-U+1247F*/
1186+ /* Bit 111 Counting Rod Numerals */
1187+#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/
1188+ /* Bit 112 Sundanese */
1189+#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */
1190+ /* Bit 113 Lepcha */
1191+#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */
1192+ /* Bit 114 Ol Chiki */
1193+#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */
1194+ /* Bit 115 Saurashtra */
1195+#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */
1196+ /* Bit 116 Kayah Li */
1197+#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */
1198+ /* Bit 117 Rejang */
1199+#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */
1200+ /* Bit 118 Cham */
1201+#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */
1202+ /* Bit 119 Ancient Symbols */
1203+#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/
1204+ /* Bit 120 Phaistos Disc */
1205+#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/
1206+ /* Bit 121 Carian */
1207+ /* Lycian */
1208+ /* Lydian */
1209+#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/
1210+ /*U+10280-U+1029F*/
1211+ /*U+10920-U+1093F*/
1212+ /* Bit 122 Domino Tiles */
1213+ /* Mahjong Tiles */
1214+#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/
1215+ /*U+1F000-U+1F02F*/
1216+ /* Bit 123-127 Reserved for process-internal usage */
1217+
1218+ /* */
1219+
1220+ /* for backward compatibility with older FreeType versions */
1221+#define TT_UCR_ARABIC_PRESENTATION_A \
1222+ TT_UCR_ARABIC_PRESENTATION_FORMS_A
1223+#define TT_UCR_ARABIC_PRESENTATION_B \
1224+ TT_UCR_ARABIC_PRESENTATION_FORMS_B
1225+
1226+#define TT_UCR_COMBINING_DIACRITICS \
1227+ TT_UCR_COMBINING_DIACRITICAL_MARKS
1228+#define TT_UCR_COMBINING_DIACRITICS_SYMB \
1229+ TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB
1230+
1231+
1232+FT_END_HEADER
1233+
1234+#endif /* TTNAMEID_H_ */
1235+
1236+
1237+/* END */
1@@ -0,0 +1,846 @@
2+/***************************************************************************/
3+/* */
4+/* tttables.h */
5+/* */
6+/* Basic SFNT/TrueType tables definitions and interface */
7+/* (specification only). */
8+/* */
9+/* Copyright 1996-2018 by */
10+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
11+/* */
12+/* This file is part of the FreeType project, and may only be used, */
13+/* modified, and distributed under the terms of the FreeType project */
14+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15+/* this file you indicate that you have read the license and */
16+/* understand and accept it fully. */
17+/* */
18+/***************************************************************************/
19+
20+
21+#ifndef TTTABLES_H_
22+#define TTTABLES_H_
23+
24+
25+#include <ft2build.h>
26+#include FT_FREETYPE_H
27+
28+#ifdef FREETYPE_H
29+#error "freetype.h of FreeType 1 has been loaded!"
30+#error "Please fix the directory search order for header files"
31+#error "so that freetype.h of FreeType 2 is found first."
32+#endif
33+
34+
35+FT_BEGIN_HEADER
36+
37+ /*************************************************************************/
38+ /* */
39+ /* <Section> */
40+ /* truetype_tables */
41+ /* */
42+ /* <Title> */
43+ /* TrueType Tables */
44+ /* */
45+ /* <Abstract> */
46+ /* TrueType specific table types and functions. */
47+ /* */
48+ /* <Description> */
49+ /* This section contains definitions of some basic tables specific to */
50+ /* TrueType and OpenType as well as some routines used to access and */
51+ /* process them. */
52+ /* */
53+ /* <Order> */
54+ /* TT_Header */
55+ /* TT_HoriHeader */
56+ /* TT_VertHeader */
57+ /* TT_OS2 */
58+ /* TT_Postscript */
59+ /* TT_PCLT */
60+ /* TT_MaxProfile */
61+ /* */
62+ /* FT_Sfnt_Tag */
63+ /* FT_Get_Sfnt_Table */
64+ /* FT_Load_Sfnt_Table */
65+ /* FT_Sfnt_Table_Info */
66+ /* */
67+ /* FT_Get_CMap_Language_ID */
68+ /* FT_Get_CMap_Format */
69+ /* */
70+ /* FT_PARAM_TAG_UNPATENTED_HINTING */
71+ /* */
72+ /*************************************************************************/
73+
74+
75+ /*************************************************************************/
76+ /* */
77+ /* <Struct> */
78+ /* TT_Header */
79+ /* */
80+ /* <Description> */
81+ /* A structure to model a TrueType font header table. All fields */
82+ /* follow the OpenType specification. */
83+ /* */
84+ typedef struct TT_Header_
85+ {
86+ FT_Fixed Table_Version;
87+ FT_Fixed Font_Revision;
88+
89+ FT_Long CheckSum_Adjust;
90+ FT_Long Magic_Number;
91+
92+ FT_UShort Flags;
93+ FT_UShort Units_Per_EM;
94+
95+ FT_Long Created [2];
96+ FT_Long Modified[2];
97+
98+ FT_Short xMin;
99+ FT_Short yMin;
100+ FT_Short xMax;
101+ FT_Short yMax;
102+
103+ FT_UShort Mac_Style;
104+ FT_UShort Lowest_Rec_PPEM;
105+
106+ FT_Short Font_Direction;
107+ FT_Short Index_To_Loc_Format;
108+ FT_Short Glyph_Data_Format;
109+
110+ } TT_Header;
111+
112+
113+ /*************************************************************************/
114+ /* */
115+ /* <Struct> */
116+ /* TT_HoriHeader */
117+ /* */
118+ /* <Description> */
119+ /* A structure to model a TrueType horizontal header, the `hhea' */
120+ /* table, as well as the corresponding horizontal metrics table, */
121+ /* `hmtx'. */
122+ /* */
123+ /* <Fields> */
124+ /* Version :: The table version. */
125+ /* */
126+ /* Ascender :: The font's ascender, i.e., the distance */
127+ /* from the baseline to the top-most of all */
128+ /* glyph points found in the font. */
129+ /* */
130+ /* This value is invalid in many fonts, as */
131+ /* it is usually set by the font designer, */
132+ /* and often reflects only a portion of the */
133+ /* glyphs found in the font (maybe ASCII). */
134+ /* */
135+ /* You should use the `sTypoAscender' field */
136+ /* of the `OS/2' table instead if you want */
137+ /* the correct one. */
138+ /* */
139+ /* Descender :: The font's descender, i.e., the distance */
140+ /* from the baseline to the bottom-most of */
141+ /* all glyph points found in the font. It */
142+ /* is negative. */
143+ /* */
144+ /* This value is invalid in many fonts, as */
145+ /* it is usually set by the font designer, */
146+ /* and often reflects only a portion of the */
147+ /* glyphs found in the font (maybe ASCII). */
148+ /* */
149+ /* You should use the `sTypoDescender' */
150+ /* field of the `OS/2' table instead if you */
151+ /* want the correct one. */
152+ /* */
153+ /* Line_Gap :: The font's line gap, i.e., the distance */
154+ /* to add to the ascender and descender to */
155+ /* get the BTB, i.e., the */
156+ /* baseline-to-baseline distance for the */
157+ /* font. */
158+ /* */
159+ /* advance_Width_Max :: This field is the maximum of all advance */
160+ /* widths found in the font. It can be */
161+ /* used to compute the maximum width of an */
162+ /* arbitrary string of text. */
163+ /* */
164+ /* min_Left_Side_Bearing :: The minimum left side bearing of all */
165+ /* glyphs within the font. */
166+ /* */
167+ /* min_Right_Side_Bearing :: The minimum right side bearing of all */
168+ /* glyphs within the font. */
169+ /* */
170+ /* xMax_Extent :: The maximum horizontal extent (i.e., the */
171+ /* `width' of a glyph's bounding box) for */
172+ /* all glyphs in the font. */
173+ /* */
174+ /* caret_Slope_Rise :: The rise coefficient of the cursor's */
175+ /* slope of the cursor (slope=rise/run). */
176+ /* */
177+ /* caret_Slope_Run :: The run coefficient of the cursor's */
178+ /* slope. */
179+ /* */
180+ /* caret_Offset :: The cursor's offset for slanted fonts. */
181+ /* */
182+ /* Reserved :: 8~reserved bytes. */
183+ /* */
184+ /* metric_Data_Format :: Always~0. */
185+ /* */
186+ /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */
187+ /* table -- this value can be smaller than */
188+ /* the total number of glyphs in the font. */
189+ /* */
190+ /* long_metrics :: A pointer into the `hmtx' table. */
191+ /* */
192+ /* short_metrics :: A pointer into the `hmtx' table. */
193+ /* */
194+ /* <Note> */
195+ /* For an OpenType variation font, the values of the following fields */
196+ /* can change after a call to @FT_Set_Var_Design_Coordinates (and */
197+ /* friends) if the font contains an `MVAR' table: `caret_Slope_Rise', */
198+ /* `caret_Slope_Run', and `caret_Offset'. */
199+ /* */
200+ typedef struct TT_HoriHeader_
201+ {
202+ FT_Fixed Version;
203+ FT_Short Ascender;
204+ FT_Short Descender;
205+ FT_Short Line_Gap;
206+
207+ FT_UShort advance_Width_Max; /* advance width maximum */
208+
209+ FT_Short min_Left_Side_Bearing; /* minimum left-sb */
210+ FT_Short min_Right_Side_Bearing; /* minimum right-sb */
211+ FT_Short xMax_Extent; /* xmax extents */
212+ FT_Short caret_Slope_Rise;
213+ FT_Short caret_Slope_Run;
214+ FT_Short caret_Offset;
215+
216+ FT_Short Reserved[4];
217+
218+ FT_Short metric_Data_Format;
219+ FT_UShort number_Of_HMetrics;
220+
221+ /* The following fields are not defined by the OpenType specification */
222+ /* but they are used to connect the metrics header to the relevant */
223+ /* `hmtx' table. */
224+
225+ void* long_metrics;
226+ void* short_metrics;
227+
228+ } TT_HoriHeader;
229+
230+
231+ /*************************************************************************/
232+ /* */
233+ /* <Struct> */
234+ /* TT_VertHeader */
235+ /* */
236+ /* <Description> */
237+ /* A structure used to model a TrueType vertical header, the `vhea' */
238+ /* table, as well as the corresponding vertical metrics table, */
239+ /* `vmtx'. */
240+ /* */
241+ /* <Fields> */
242+ /* Version :: The table version. */
243+ /* */
244+ /* Ascender :: The font's ascender, i.e., the distance */
245+ /* from the baseline to the top-most of */
246+ /* all glyph points found in the font. */
247+ /* */
248+ /* This value is invalid in many fonts, as */
249+ /* it is usually set by the font designer, */
250+ /* and often reflects only a portion of */
251+ /* the glyphs found in the font (maybe */
252+ /* ASCII). */
253+ /* */
254+ /* You should use the `sTypoAscender' */
255+ /* field of the `OS/2' table instead if */
256+ /* you want the correct one. */
257+ /* */
258+ /* Descender :: The font's descender, i.e., the */
259+ /* distance from the baseline to the */
260+ /* bottom-most of all glyph points found */
261+ /* in the font. It is negative. */
262+ /* */
263+ /* This value is invalid in many fonts, as */
264+ /* it is usually set by the font designer, */
265+ /* and often reflects only a portion of */
266+ /* the glyphs found in the font (maybe */
267+ /* ASCII). */
268+ /* */
269+ /* You should use the `sTypoDescender' */
270+ /* field of the `OS/2' table instead if */
271+ /* you want the correct one. */
272+ /* */
273+ /* Line_Gap :: The font's line gap, i.e., the distance */
274+ /* to add to the ascender and descender to */
275+ /* get the BTB, i.e., the */
276+ /* baseline-to-baseline distance for the */
277+ /* font. */
278+ /* */
279+ /* advance_Height_Max :: This field is the maximum of all */
280+ /* advance heights found in the font. It */
281+ /* can be used to compute the maximum */
282+ /* height of an arbitrary string of text. */
283+ /* */
284+ /* min_Top_Side_Bearing :: The minimum top side bearing of all */
285+ /* glyphs within the font. */
286+ /* */
287+ /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */
288+ /* glyphs within the font. */
289+ /* */
290+ /* yMax_Extent :: The maximum vertical extent (i.e., the */
291+ /* `height' of a glyph's bounding box) for */
292+ /* all glyphs in the font. */
293+ /* */
294+ /* caret_Slope_Rise :: The rise coefficient of the cursor's */
295+ /* slope of the cursor (slope=rise/run). */
296+ /* */
297+ /* caret_Slope_Run :: The run coefficient of the cursor's */
298+ /* slope. */
299+ /* */
300+ /* caret_Offset :: The cursor's offset for slanted fonts. */
301+ /* */
302+ /* Reserved :: 8~reserved bytes. */
303+ /* */
304+ /* metric_Data_Format :: Always~0. */
305+ /* */
306+ /* number_Of_VMetrics :: Number of VMetrics entries in the */
307+ /* `vmtx' table -- this value can be */
308+ /* smaller than the total number of glyphs */
309+ /* in the font. */
310+ /* */
311+ /* long_metrics :: A pointer into the `vmtx' table. */
312+ /* */
313+ /* short_metrics :: A pointer into the `vmtx' table. */
314+ /* */
315+ /* <Note> */
316+ /* For an OpenType variation font, the values of the following fields */
317+ /* can change after a call to @FT_Set_Var_Design_Coordinates (and */
318+ /* friends) if the font contains an `MVAR' table: `Ascender', */
319+ /* `Descender', `Line_Gap', `caret_Slope_Rise', `caret_Slope_Run', */
320+ /* and `caret_Offset'. */
321+ /* */
322+ typedef struct TT_VertHeader_
323+ {
324+ FT_Fixed Version;
325+ FT_Short Ascender;
326+ FT_Short Descender;
327+ FT_Short Line_Gap;
328+
329+ FT_UShort advance_Height_Max; /* advance height maximum */
330+
331+ FT_Short min_Top_Side_Bearing; /* minimum top-sb */
332+ FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */
333+ FT_Short yMax_Extent; /* ymax extents */
334+ FT_Short caret_Slope_Rise;
335+ FT_Short caret_Slope_Run;
336+ FT_Short caret_Offset;
337+
338+ FT_Short Reserved[4];
339+
340+ FT_Short metric_Data_Format;
341+ FT_UShort number_Of_VMetrics;
342+
343+ /* The following fields are not defined by the OpenType specification */
344+ /* but they are used to connect the metrics header to the relevant */
345+ /* `vmtx' table. */
346+
347+ void* long_metrics;
348+ void* short_metrics;
349+
350+ } TT_VertHeader;
351+
352+
353+ /*************************************************************************/
354+ /* */
355+ /* <Struct> */
356+ /* TT_OS2 */
357+ /* */
358+ /* <Description> */
359+ /* A structure to model a TrueType `OS/2' table. All fields comply */
360+ /* to the OpenType specification. */
361+ /* */
362+ /* Note that we now support old Mac fonts that do not include an */
363+ /* `OS/2' table. In this case, the `version' field is always set to */
364+ /* 0xFFFF. */
365+ /* */
366+ /* <Note> */
367+ /* For an OpenType variation font, the values of the following fields */
368+ /* can change after a call to @FT_Set_Var_Design_Coordinates (and */
369+ /* friends) if the font contains an `MVAR' table: `sCapHeight', */
370+ /* `sTypoAscender', `sTypoDescender', `sTypoLineGap', `sxHeight', */
371+ /* `usWinAscent', `usWinDescent', `yStrikeoutPosition', */
372+ /* `yStrikeoutSize', `ySubscriptXOffset', `ySubScriptXSize', */
373+ /* `ySubscriptYOffset', `ySubscriptYSize', `ySuperscriptXOffset', */
374+ /* `ySuperscriptXSize', `ySuperscriptYOffset', and */
375+ /* `ySuperscriptYSize'. */
376+ /* */
377+ /* Possible values for bits in the `ulUnicodeRangeX' fields are given */
378+ /* by the @TT_UCR_XXX macros. */
379+ /* */
380+
381+ typedef struct TT_OS2_
382+ {
383+ FT_UShort version; /* 0x0001 - more or 0xFFFF */
384+ FT_Short xAvgCharWidth;
385+ FT_UShort usWeightClass;
386+ FT_UShort usWidthClass;
387+ FT_UShort fsType;
388+ FT_Short ySubscriptXSize;
389+ FT_Short ySubscriptYSize;
390+ FT_Short ySubscriptXOffset;
391+ FT_Short ySubscriptYOffset;
392+ FT_Short ySuperscriptXSize;
393+ FT_Short ySuperscriptYSize;
394+ FT_Short ySuperscriptXOffset;
395+ FT_Short ySuperscriptYOffset;
396+ FT_Short yStrikeoutSize;
397+ FT_Short yStrikeoutPosition;
398+ FT_Short sFamilyClass;
399+
400+ FT_Byte panose[10];
401+
402+ FT_ULong ulUnicodeRange1; /* Bits 0-31 */
403+ FT_ULong ulUnicodeRange2; /* Bits 32-63 */
404+ FT_ULong ulUnicodeRange3; /* Bits 64-95 */
405+ FT_ULong ulUnicodeRange4; /* Bits 96-127 */
406+
407+ FT_Char achVendID[4];
408+
409+ FT_UShort fsSelection;
410+ FT_UShort usFirstCharIndex;
411+ FT_UShort usLastCharIndex;
412+ FT_Short sTypoAscender;
413+ FT_Short sTypoDescender;
414+ FT_Short sTypoLineGap;
415+ FT_UShort usWinAscent;
416+ FT_UShort usWinDescent;
417+
418+ /* only version 1 and higher: */
419+
420+ FT_ULong ulCodePageRange1; /* Bits 0-31 */
421+ FT_ULong ulCodePageRange2; /* Bits 32-63 */
422+
423+ /* only version 2 and higher: */
424+
425+ FT_Short sxHeight;
426+ FT_Short sCapHeight;
427+ FT_UShort usDefaultChar;
428+ FT_UShort usBreakChar;
429+ FT_UShort usMaxContext;
430+
431+ /* only version 5 and higher: */
432+
433+ FT_UShort usLowerOpticalPointSize; /* in twips (1/20th points) */
434+ FT_UShort usUpperOpticalPointSize; /* in twips (1/20th points) */
435+
436+ } TT_OS2;
437+
438+
439+ /*************************************************************************/
440+ /* */
441+ /* <Struct> */
442+ /* TT_Postscript */
443+ /* */
444+ /* <Description> */
445+ /* A structure to model a TrueType `post' table. All fields comply */
446+ /* to the OpenType specification. This structure does not reference */
447+ /* a font's PostScript glyph names; use @FT_Get_Glyph_Name to */
448+ /* retrieve them. */
449+ /* */
450+ /* <Note> */
451+ /* For an OpenType variation font, the values of the following fields */
452+ /* can change after a call to @FT_Set_Var_Design_Coordinates (and */
453+ /* friends) if the font contains an `MVAR' table: `underlinePosition' */
454+ /* and `underlineThickness'. */
455+ /* */
456+ typedef struct TT_Postscript_
457+ {
458+ FT_Fixed FormatType;
459+ FT_Fixed italicAngle;
460+ FT_Short underlinePosition;
461+ FT_Short underlineThickness;
462+ FT_ULong isFixedPitch;
463+ FT_ULong minMemType42;
464+ FT_ULong maxMemType42;
465+ FT_ULong minMemType1;
466+ FT_ULong maxMemType1;
467+
468+ /* Glyph names follow in the `post' table, but we don't */
469+ /* load them by default. */
470+
471+ } TT_Postscript;
472+
473+
474+ /*************************************************************************/
475+ /* */
476+ /* <Struct> */
477+ /* TT_PCLT */
478+ /* */
479+ /* <Description> */
480+ /* A structure to model a TrueType `PCLT' table. All fields comply */
481+ /* to the OpenType specification. */
482+ /* */
483+ typedef struct TT_PCLT_
484+ {
485+ FT_Fixed Version;
486+ FT_ULong FontNumber;
487+ FT_UShort Pitch;
488+ FT_UShort xHeight;
489+ FT_UShort Style;
490+ FT_UShort TypeFamily;
491+ FT_UShort CapHeight;
492+ FT_UShort SymbolSet;
493+ FT_Char TypeFace[16];
494+ FT_Char CharacterComplement[8];
495+ FT_Char FileName[6];
496+ FT_Char StrokeWeight;
497+ FT_Char WidthType;
498+ FT_Byte SerifStyle;
499+ FT_Byte Reserved;
500+
501+ } TT_PCLT;
502+
503+
504+ /*************************************************************************/
505+ /* */
506+ /* <Struct> */
507+ /* TT_MaxProfile */
508+ /* */
509+ /* <Description> */
510+ /* The maximum profile (`maxp') table contains many max values, which */
511+ /* can be used to pre-allocate arrays for speeding up glyph loading */
512+ /* and hinting. */
513+ /* */
514+ /* <Fields> */
515+ /* version :: The version number. */
516+ /* */
517+ /* numGlyphs :: The number of glyphs in this TrueType */
518+ /* font. */
519+ /* */
520+ /* maxPoints :: The maximum number of points in a */
521+ /* non-composite TrueType glyph. See also */
522+ /* `maxCompositePoints'. */
523+ /* */
524+ /* maxContours :: The maximum number of contours in a */
525+ /* non-composite TrueType glyph. See also */
526+ /* `maxCompositeContours'. */
527+ /* */
528+ /* maxCompositePoints :: The maximum number of points in a */
529+ /* composite TrueType glyph. See also */
530+ /* `maxPoints'. */
531+ /* */
532+ /* maxCompositeContours :: The maximum number of contours in a */
533+ /* composite TrueType glyph. See also */
534+ /* `maxContours'. */
535+ /* */
536+ /* maxZones :: The maximum number of zones used for */
537+ /* glyph hinting. */
538+ /* */
539+ /* maxTwilightPoints :: The maximum number of points in the */
540+ /* twilight zone used for glyph hinting. */
541+ /* */
542+ /* maxStorage :: The maximum number of elements in the */
543+ /* storage area used for glyph hinting. */
544+ /* */
545+ /* maxFunctionDefs :: The maximum number of function */
546+ /* definitions in the TrueType bytecode for */
547+ /* this font. */
548+ /* */
549+ /* maxInstructionDefs :: The maximum number of instruction */
550+ /* definitions in the TrueType bytecode for */
551+ /* this font. */
552+ /* */
553+ /* maxStackElements :: The maximum number of stack elements used */
554+ /* during bytecode interpretation. */
555+ /* */
556+ /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */
557+ /* used for glyph hinting. */
558+ /* */
559+ /* maxComponentElements :: The maximum number of simple (i.e., non- */
560+ /* composite) glyphs in a composite glyph. */
561+ /* */
562+ /* maxComponentDepth :: The maximum nesting depth of composite */
563+ /* glyphs. */
564+ /* */
565+ /* <Note> */
566+ /* This structure is only used during font loading. */
567+ /* */
568+ typedef struct TT_MaxProfile_
569+ {
570+ FT_Fixed version;
571+ FT_UShort numGlyphs;
572+ FT_UShort maxPoints;
573+ FT_UShort maxContours;
574+ FT_UShort maxCompositePoints;
575+ FT_UShort maxCompositeContours;
576+ FT_UShort maxZones;
577+ FT_UShort maxTwilightPoints;
578+ FT_UShort maxStorage;
579+ FT_UShort maxFunctionDefs;
580+ FT_UShort maxInstructionDefs;
581+ FT_UShort maxStackElements;
582+ FT_UShort maxSizeOfInstructions;
583+ FT_UShort maxComponentElements;
584+ FT_UShort maxComponentDepth;
585+
586+ } TT_MaxProfile;
587+
588+
589+ /*************************************************************************/
590+ /* */
591+ /* <Enum> */
592+ /* FT_Sfnt_Tag */
593+ /* */
594+ /* <Description> */
595+ /* An enumeration to specify indices of SFNT tables loaded and parsed */
596+ /* by FreeType during initialization of an SFNT font. Used in the */
597+ /* @FT_Get_Sfnt_Table API function. */
598+ /* */
599+ /* <Values> */
600+ /* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */
601+ /* */
602+ /* FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure. */
603+ /* */
604+ /* FT_SFNT_OS2 :: To access the font's @TT_OS2 structure. */
605+ /* */
606+ /* FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure. */
607+ /* */
608+ /* FT_SFNT_VHEA :: To access the font's @TT_VertHeader structure. */
609+ /* */
610+ /* FT_SFNT_POST :: To access the font's @TT_Postscript structure. */
611+ /* */
612+ /* FT_SFNT_PCLT :: To access the font's @TT_PCLT structure. */
613+ /* */
614+ typedef enum FT_Sfnt_Tag_
615+ {
616+ FT_SFNT_HEAD,
617+ FT_SFNT_MAXP,
618+ FT_SFNT_OS2,
619+ FT_SFNT_HHEA,
620+ FT_SFNT_VHEA,
621+ FT_SFNT_POST,
622+ FT_SFNT_PCLT,
623+
624+ FT_SFNT_MAX
625+
626+ } FT_Sfnt_Tag;
627+
628+ /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */
629+ /* values instead */
630+#define ft_sfnt_head FT_SFNT_HEAD
631+#define ft_sfnt_maxp FT_SFNT_MAXP
632+#define ft_sfnt_os2 FT_SFNT_OS2
633+#define ft_sfnt_hhea FT_SFNT_HHEA
634+#define ft_sfnt_vhea FT_SFNT_VHEA
635+#define ft_sfnt_post FT_SFNT_POST
636+#define ft_sfnt_pclt FT_SFNT_PCLT
637+
638+
639+ /*************************************************************************/
640+ /* */
641+ /* <Function> */
642+ /* FT_Get_Sfnt_Table */
643+ /* */
644+ /* <Description> */
645+ /* Return a pointer to a given SFNT table stored within a face. */
646+ /* */
647+ /* <Input> */
648+ /* face :: A handle to the source. */
649+ /* */
650+ /* tag :: The index of the SFNT table. */
651+ /* */
652+ /* <Return> */
653+ /* A type-less pointer to the table. This will be NULL in case of */
654+ /* error, or if the corresponding table was not found *OR* loaded */
655+ /* from the file. */
656+ /* */
657+ /* Use a typecast according to `tag' to access the structure */
658+ /* elements. */
659+ /* */
660+ /* <Note> */
661+ /* The table is owned by the face object and disappears with it. */
662+ /* */
663+ /* This function is only useful to access SFNT tables that are loaded */
664+ /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */
665+ /* a list. */
666+ /* */
667+ /* Here an example how to access the `vhea' table: */
668+ /* */
669+ /* { */
670+ /* TT_VertHeader* vert_header; */
671+ /* */
672+ /* */
673+ /* vert_header = */
674+ /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); */
675+ /* } */
676+ /* */
677+ FT_EXPORT( void* )
678+ FT_Get_Sfnt_Table( FT_Face face,
679+ FT_Sfnt_Tag tag );
680+
681+
682+ /**************************************************************************
683+ *
684+ * @function:
685+ * FT_Load_Sfnt_Table
686+ *
687+ * @description:
688+ * Load any SFNT font table into client memory.
689+ *
690+ * @input:
691+ * face ::
692+ * A handle to the source face.
693+ *
694+ * tag ::
695+ * The four-byte tag of the table to load. Use value~0 if you want
696+ * to access the whole font file. Otherwise, you can use one of the
697+ * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new
698+ * one with @FT_MAKE_TAG.
699+ *
700+ * offset ::
701+ * The starting offset in the table (or file if tag~==~0).
702+ *
703+ * @output:
704+ * buffer ::
705+ * The target buffer address. The client must ensure that the memory
706+ * array is big enough to hold the data.
707+ *
708+ * @inout:
709+ * length ::
710+ * If the `length' parameter is NULL, try to load the whole table.
711+ * Return an error code if it fails.
712+ *
713+ * Else, if `*length' is~0, exit immediately while returning the
714+ * table's (or file) full size in it.
715+ *
716+ * Else the number of bytes to read from the table or file, from the
717+ * starting offset.
718+ *
719+ * @return:
720+ * FreeType error code. 0~means success.
721+ *
722+ * @note:
723+ * If you need to determine the table's length you should first call this
724+ * function with `*length' set to~0, as in the following example:
725+ *
726+ * {
727+ * FT_ULong length = 0;
728+ *
729+ *
730+ * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length );
731+ * if ( error ) { ... table does not exist ... }
732+ *
733+ * buffer = malloc( length );
734+ * if ( buffer == NULL ) { ... not enough memory ... }
735+ *
736+ * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
737+ * if ( error ) { ... could not load table ... }
738+ * }
739+ *
740+ * Note that structures like @TT_Header or @TT_OS2 can't be used with
741+ * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that
742+ * those structures depend on the processor architecture, with varying
743+ * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian).
744+ *
745+ */
746+ FT_EXPORT( FT_Error )
747+ FT_Load_Sfnt_Table( FT_Face face,
748+ FT_ULong tag,
749+ FT_Long offset,
750+ FT_Byte* buffer,
751+ FT_ULong* length );
752+
753+
754+ /**************************************************************************
755+ *
756+ * @function:
757+ * FT_Sfnt_Table_Info
758+ *
759+ * @description:
760+ * Return information on an SFNT table.
761+ *
762+ * @input:
763+ * face ::
764+ * A handle to the source face.
765+ *
766+ * table_index ::
767+ * The index of an SFNT table. The function returns
768+ * FT_Err_Table_Missing for an invalid value.
769+ *
770+ * @inout:
771+ * tag ::
772+ * The name tag of the SFNT table. If the value is NULL, `table_index'
773+ * is ignored, and `length' returns the number of SFNT tables in the
774+ * font.
775+ *
776+ * @output:
777+ * length ::
778+ * The length of the SFNT table (or the number of SFNT tables, depending
779+ * on `tag').
780+ *
781+ * @return:
782+ * FreeType error code. 0~means success.
783+ *
784+ * @note:
785+ * While parsing fonts, FreeType handles SFNT tables with length zero as
786+ * missing.
787+ *
788+ */
789+ FT_EXPORT( FT_Error )
790+ FT_Sfnt_Table_Info( FT_Face face,
791+ FT_UInt table_index,
792+ FT_ULong *tag,
793+ FT_ULong *length );
794+
795+
796+ /*************************************************************************/
797+ /* */
798+ /* <Function> */
799+ /* FT_Get_CMap_Language_ID */
800+ /* */
801+ /* <Description> */
802+ /* Return cmap language ID as specified in the OpenType standard. */
803+ /* Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. */
804+ /* */
805+ /* <Input> */
806+ /* charmap :: */
807+ /* The target charmap. */
808+ /* */
809+ /* <Return> */
810+ /* The language ID of `charmap'. If `charmap' doesn't belong to an */
811+ /* SFNT face, just return~0 as the default value. */
812+ /* */
813+ /* For a format~14 cmap (to access Unicode IVS), the return value is */
814+ /* 0xFFFFFFFF. */
815+ /* */
816+ FT_EXPORT( FT_ULong )
817+ FT_Get_CMap_Language_ID( FT_CharMap charmap );
818+
819+
820+ /*************************************************************************/
821+ /* */
822+ /* <Function> */
823+ /* FT_Get_CMap_Format */
824+ /* */
825+ /* <Description> */
826+ /* Return the format of an SFNT `cmap' table. */
827+ /* */
828+ /* <Input> */
829+ /* charmap :: */
830+ /* The target charmap. */
831+ /* */
832+ /* <Return> */
833+ /* The format of `charmap'. If `charmap' doesn't belong to an SFNT */
834+ /* face, return -1. */
835+ /* */
836+ FT_EXPORT( FT_Long )
837+ FT_Get_CMap_Format( FT_CharMap charmap );
838+
839+ /* */
840+
841+
842+FT_END_HEADER
843+
844+#endif /* TTTABLES_H_ */
845+
846+
847+/* END */
1@@ -0,0 +1,121 @@
2+/***************************************************************************/
3+/* */
4+/* tttags.h */
5+/* */
6+/* Tags for TrueType and OpenType tables (specification only). */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+#ifndef TTAGS_H_
21+#define TTAGS_H_
22+
23+
24+#include <ft2build.h>
25+#include FT_FREETYPE_H
26+
27+#ifdef FREETYPE_H
28+#error "freetype.h of FreeType 1 has been loaded!"
29+#error "Please fix the directory search order for header files"
30+#error "so that freetype.h of FreeType 2 is found first."
31+#endif
32+
33+
34+FT_BEGIN_HEADER
35+
36+
37+#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' )
38+#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' )
39+#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' )
40+#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' )
41+#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' )
42+#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
43+#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' )
44+#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' )
45+#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' )
46+#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
47+#define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' )
48+#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' )
49+#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
50+#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' )
51+#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
52+#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
53+#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' )
54+#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
55+#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
56+#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' )
57+#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' )
58+#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' )
59+#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' )
60+#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' )
61+#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' )
62+#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' )
63+#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
64+#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
65+#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' )
66+#define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' )
67+#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' )
68+#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' )
69+#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' )
70+#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' )
71+#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' )
72+#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' )
73+#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' )
74+#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' )
75+#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
76+#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
77+#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' )
78+#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' )
79+#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
80+#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' )
81+#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' )
82+#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
83+#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' )
84+#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' )
85+#define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' )
86+#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' )
87+#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' )
88+#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
89+#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' )
90+#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' )
91+#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' )
92+#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' )
93+#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' )
94+#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' )
95+#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' )
96+#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' )
97+#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' )
98+#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' )
99+#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' )
100+#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' )
101+#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' )
102+#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' )
103+#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' )
104+#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' )
105+#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' )
106+#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' )
107+#define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' )
108+#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' )
109+
110+/* used by "Keyboard.dfont" on legacy Mac OS X */
111+#define TTAG_0xA5kbd FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' )
112+
113+/* used by "LastResort.dfont" on legacy Mac OS X */
114+#define TTAG_0xA5lst FT_MAKE_TAG( 0xA5, 'l', 's', 't' )
115+
116+
117+FT_END_HEADER
118+
119+#endif /* TTAGS_H_ */
120+
121+
122+/* END */
+42,
-0
1@@ -0,0 +1,42 @@
2+/***************************************************************************/
3+/* */
4+/* ft2build.h */
5+/* */
6+/* FreeType 2 build and setup macros. */
7+/* */
8+/* Copyright 1996-2018 by */
9+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10+/* */
11+/* This file is part of the FreeType project, and may only be used, */
12+/* modified, and distributed under the terms of the FreeType project */
13+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14+/* this file you indicate that you have read the license and */
15+/* understand and accept it fully. */
16+/* */
17+/***************************************************************************/
18+
19+
20+ /*************************************************************************/
21+ /* */
22+ /* This is the `entry point' for FreeType header file inclusions. It is */
23+ /* the only header file which should be included directly; all other */
24+ /* FreeType header files should be accessed with macro names (after */
25+ /* including `ft2build.h'). */
26+ /* */
27+ /* A typical example is */
28+ /* */
29+ /* #include <ft2build.h> */
30+ /* #include FT_FREETYPE_H */
31+ /* */
32+ /*************************************************************************/
33+
34+
35+#ifndef FT2BUILD_H_
36+#define FT2BUILD_H_
37+
38+#include <freetype/config/ftheader.h>
39+
40+#endif /* FT2BUILD_H_ */
41+
42+
43+/* END */
+172,
-0
1@@ -0,0 +1,172 @@
2+/*
3+ * Copyright 2009, Michael Lotz, mmlr@mlotz.ch.
4+ * Distributed under the terms of the MIT License.
5+ */
6+#ifndef _LOCKS_H_
7+#define _LOCKS_H_
8+
9+#include <OS.h>
10+
11+#ifdef __cplusplus
12+extern "C" {
13+#endif
14+
15+typedef struct mutex {
16+ const char* name;
17+ int32 lock;
18+ uint32 flags;
19+} mutex;
20+
21+#define MUTEX_FLAG_CLONE_NAME 0x1
22+#define MUTEX_FLAG_ADAPTIVE 0x2
23+#define MUTEX_INITIALIZER(name) { name, 0, 0 }
24+
25+#define mutex_init(lock, name) __mutex_init(lock, name)
26+#define mutex_init_etc(lock, name, flags) __mutex_init_etc(lock, name, flags)
27+#define mutex_destroy(lock) __mutex_destroy(lock)
28+#define mutex_lock(lock) __mutex_lock(lock)
29+#define mutex_unlock(lock) __mutex_unlock(lock)
30+
31+void __mutex_init(mutex *lock, const char *name);
32+void __mutex_init_etc(mutex *lock, const char *name, uint32 flags);
33+void __mutex_destroy(mutex *lock);
34+status_t __mutex_lock(mutex *lock);
35+void __mutex_unlock(mutex *lock);
36+
37+
38+typedef struct rw_lock {
39+ mutex lock;
40+ struct rw_lock_waiter * waiters;
41+ struct rw_lock_waiter * last_waiter;
42+ thread_id holder;
43+ int32 reader_count;
44+ int32 writer_count;
45+ int32 owner_count;
46+} rw_lock;
47+
48+#define RW_LOCK_FLAG_CLONE_NAME MUTEX_FLAG_CLONE_NAME
49+#define RW_LOCK_INITIALIZER(name) { MUTEX_INITIALIZER(name), NULL, \
50+ NULL, -1, 0, 0, 0 }
51+
52+#define rw_lock_init(lock, name) __rw_lock_init(lock, name)
53+#define rw_lock_init_etc(lock, name, flags) \
54+ __rw_lock_init_etc(lock, name, flags)
55+#define rw_lock_destroy(lock) __rw_lock_destroy(lock)
56+#define rw_lock_read_lock(lock) __rw_lock_read_lock(lock)
57+#define rw_lock_read_unlock(lock) __rw_lock_read_unlock(lock)
58+#define rw_lock_write_lock(lock) __rw_lock_write_lock(lock)
59+#define rw_lock_write_unlock(lock) __rw_lock_write_unlock(lock)
60+
61+void __rw_lock_init(rw_lock *lock, const char *name);
62+void __rw_lock_init_etc(rw_lock *lock, const char *name, uint32 flags);
63+void __rw_lock_destroy(rw_lock *lock);
64+status_t __rw_lock_read_lock(rw_lock *lock);
65+status_t __rw_lock_read_unlock(rw_lock *lock);
66+status_t __rw_lock_write_lock(rw_lock *lock);
67+status_t __rw_lock_write_unlock(rw_lock *lock);
68+
69+
70+typedef struct recursive_lock {
71+ mutex lock;
72+ thread_id holder;
73+ int32 recursion;
74+} recursive_lock;
75+
76+#define RECURSIVE_LOCK_FLAG_CLONE_NAME MUTEX_FLAG_CLONE_NAME
77+#define RECURSIVE_LOCK_INITIALIZER(name) { MUTEX_INITIALIZER(name), -1, 0 }
78+
79+#define recursive_lock_init(lock, name) __recursive_lock_init(lock, name)
80+#define recursive_lock_init_etc(lock, name, flags) \
81+ __recursive_lock_init_etc(lock, name, flags)
82+#define recursive_lock_destroy(lock) __recursive_lock_destroy(lock)
83+#define recursive_lock_lock(lock) __recursive_lock_lock(lock)
84+#define recursive_lock_unlock(lock) __recursive_lock_unlock(lock)
85+#define recursive_lock_get_recursion(lock) __recursive_lock_get_recursion(lock)
86+
87+void __recursive_lock_init(recursive_lock *lock, const char *name);
88+void __recursive_lock_init_etc(recursive_lock *lock, const char *name,
89+ uint32 flags);
90+void __recursive_lock_destroy(recursive_lock *lock);
91+status_t __recursive_lock_lock(recursive_lock *lock);
92+void __recursive_lock_unlock(recursive_lock *lock);
93+int32 __recursive_lock_get_recursion(recursive_lock *lock);
94+
95+
96+#define INIT_ONCE_UNINITIALIZED -1
97+#define INIT_ONCE_INITIALIZED -4
98+
99+status_t __init_once(int32* control, status_t (*initRoutine)(void*),
100+ void* data);
101+
102+#ifdef __cplusplus
103+} // extern "C"
104+
105+
106+#include <AutoLocker.h>
107+
108+class MutexLocking {
109+public:
110+ inline bool Lock(struct mutex *lock)
111+ {
112+ return mutex_lock(lock) == B_OK;
113+ }
114+
115+ inline void Unlock(struct mutex *lock)
116+ {
117+ mutex_unlock(lock);
118+ }
119+};
120+
121+typedef AutoLocker<mutex, MutexLocking> MutexLocker;
122+
123+
124+class RecursiveLockLocking {
125+public:
126+ inline bool Lock(recursive_lock *lockable)
127+ {
128+ return recursive_lock_lock(lockable) == B_OK;
129+ }
130+
131+ inline void Unlock(recursive_lock *lockable)
132+ {
133+ recursive_lock_unlock(lockable);
134+ }
135+};
136+
137+typedef AutoLocker<recursive_lock, RecursiveLockLocking> RecursiveLocker;
138+
139+
140+class RWLockReadLocking {
141+public:
142+ inline bool Lock(struct rw_lock *lock)
143+ {
144+ return rw_lock_read_lock(lock) == B_OK;
145+ }
146+
147+ inline void Unlock(struct rw_lock *lock)
148+ {
149+ rw_lock_read_unlock(lock);
150+ }
151+};
152+
153+
154+class RWLockWriteLocking {
155+public:
156+ inline bool Lock(struct rw_lock *lock)
157+ {
158+ return rw_lock_write_lock(lock) == B_OK;
159+ }
160+
161+ inline void Unlock(struct rw_lock *lock)
162+ {
163+ rw_lock_write_unlock(lock);
164+ }
165+};
166+
167+
168+typedef AutoLocker<rw_lock, RWLockReadLocking> ReadLocker;
169+typedef AutoLocker<rw_lock, RWLockWriteLocking> WriteLocker;
170+
171+#endif // __cplusplus
172+
173+#endif // _LOCKS_H_
1@@ -0,0 +1 @@
2+#include <../private/kernel/util/DoublyLinkedList.h>
+122,
-0
1@@ -0,0 +1,122 @@
2+#if !defined(_VIDEO_OVERLAY_H_)
3+#define _VIDEO_OVERLAY_H_
4+
5+/*
6+ Copyright Be Incorporated.
7+ This file will eventually be merged into Accelerant.h once the API is finalized.
8+*/
9+
10+#include <Accelerant.h>
11+#include <GraphicsDefs.h>
12+
13+#if defined(__cplusplus)
14+extern "C" {
15+#endif
16+
17+enum {
18+ B_SUPPORTS_OVERLAYS = 1U << 31 // part of display_mode.flags
19+};
20+
21+enum {
22+ B_OVERLAY_COUNT = 0x08000000,
23+ B_OVERLAY_SUPPORTED_SPACES,
24+ B_OVERLAY_SUPPORTED_FEATURES,
25+ B_ALLOCATE_OVERLAY_BUFFER,
26+ B_RELEASE_OVERLAY_BUFFER,
27+ B_GET_OVERLAY_CONSTRAINTS,
28+ B_ALLOCATE_OVERLAY,
29+ B_RELEASE_OVERLAY,
30+ B_CONFIGURE_OVERLAY
31+};
32+
33+typedef struct {
34+ uint32 space; /* color_space of buffer */
35+ uint16 width; /* width in pixels */
36+ uint16 height; /* height in lines */
37+ uint32 bytes_per_row; /* number of bytes in one line */
38+ void *buffer; /* pointer to first byte of overlay buffer in virtual memory */
39+ void *buffer_dma; /* pointer to first byte of overlay buffer in physical memory for DMA */
40+} overlay_buffer;
41+
42+typedef struct {
43+ uint16 h_start;
44+ uint16 v_start;
45+ uint16 width;
46+ uint16 height;
47+} overlay_view;
48+
49+enum {
50+ B_OVERLAY_COLOR_KEY = 1 << 0,
51+ B_OVERLAY_CHROMA_KEY = 1 << 1,
52+ B_OVERLAY_HORIZONTAL_FILTERING = 1 << 2,
53+ B_OVERLAY_VERTICAL_FILTERING = 1 << 3,
54+ B_OVERLAY_HORIZONTAL_MIRRORING = 1 << 4,
55+ B_OVERLAY_KEYING_USES_ALPHA = 1 << 5
56+};
57+
58+typedef struct {
59+ uint8 value; /* if DAC color component of graphic pixel & mask == value, */
60+ uint8 mask; /* then show overlay pixel, else show graphic pixel */
61+} overlay_key_color;
62+
63+typedef struct {
64+ int16 h_start; /* Top left un-clipped corner of the window in the virtual display */
65+ int16 v_start; /* Note that these are _signed_ values */
66+ uint16 width; /* un-clipped width of the overlay window */
67+ uint16 height; /* un-clipped height of the overlay window */
68+
69+ uint16 offset_left; /* that portion of the overlay_window which is actually displayed */
70+ uint16 offset_top; /* ie, the first line displayed is v_start + offset_top */
71+ uint16 offset_right; /* and the first pixel displayed is h_start + offset_left */
72+ uint16 offset_bottom;
73+
74+ overlay_key_color red; /* when using color keying, all components must match */
75+ overlay_key_color green;
76+ overlay_key_color blue;
77+ overlay_key_color alpha;
78+ uint32 flags; /* which features should be enabled. See enum above. */
79+} overlay_window;
80+
81+typedef struct {
82+ uint16 min;
83+ uint16 max;
84+} overlay_uint16_minmax;
85+
86+typedef struct {
87+ float min;
88+ float max;
89+} overlay_float_minmax;
90+
91+typedef struct {
92+ uint16 h_alignment; /* alignments: a 1 bit set in every bit which must be zero */
93+ uint16 v_alignment;
94+ uint16 width_alignment;
95+ uint16 height_alignment;
96+ overlay_uint16_minmax width; /* min and max sizes in each axis */
97+ overlay_uint16_minmax height;
98+} overlay_limits;
99+
100+typedef struct {
101+ overlay_limits view;
102+ overlay_limits window;
103+ overlay_float_minmax h_scale;
104+ overlay_float_minmax v_scale;
105+} overlay_constraints;
106+
107+typedef void * overlay_token;
108+
109+typedef uint32 (*overlay_count)(const display_mode *dm);
110+typedef const uint32 *(*overlay_supported_spaces)(const display_mode *dm);
111+typedef uint32 (*overlay_supported_features)(uint32 a_color_space);
112+typedef const overlay_buffer *(*allocate_overlay_buffer)(color_space cs, uint16 width, uint16 height);
113+typedef status_t (*release_overlay_buffer)(const overlay_buffer *ob);
114+typedef status_t (*get_overlay_constraints)(const display_mode *dm, const overlay_buffer *ob, overlay_constraints *oc);
115+typedef overlay_token (*allocate_overlay)(void);
116+typedef status_t (*release_overlay)(overlay_token ot);
117+typedef status_t (*configure_overlay)(overlay_token ot, const overlay_buffer *ob, const overlay_window *ow, const overlay_view *ov);
118+
119+#if defined(__cplusplus)
120+}
121+#endif
122+
123+#endif
1@@ -0,0 +1,22 @@
2+# --- DO NOT MODIFY THIS LINE -- AUTO-DEPENDS FOLLOW ---
3+objects.x86_64-cc13-release/FlatDecorator.o : includes/RGBColor.h \
4+ includes/PatternHandler.h includes/DrawingEngine.h \
5+ includes/DesktopSettings.h FlatDecorator.h includes/HWInterface.h \
6+ includes/ServerProtocolStructs.h includes/AutoDeleter.h \
7+ includes/SATDecorator.h DecorManager.h includes/ServerCursor.h \
8+ includes/MultiLocker.h includes/IntRect.h includes/video_overlay.h \
9+ includes/StackAndTile.h includes/DefaultWindowBehaviour.h \
10+ includes/DefaultDecorator.h includes/DecorManager.h Decorator.h \
11+ includes/DecorInfo.h includes/ServerBitmap.h includes/locks.h \
12+ includes/IntPoint.h includes/WindowList.h includes/DesktopListener.h \
13+ includes/MagneticBorder.h includes/Decorator.h \
14+ includes/WindowBehaviour.h includes/TabDecorator.h includes/DrawState.h \
15+ includes/ClientMemoryAllocator.h includes/AutoLocker.h \
16+ includes/ServerLink.h includes/util/DoublyLinkedList.h \
17+ includes/SimpleTransform.h includes/ServerFont.h includes/LinkSender.h \
18+ includes/LinkReceiver.h includes/Transformable.h \
19+ includes/GlobalSubpixelSettings.h includes/FontFamily.h \
20+ includes/agg_trans_affine.h includes/FontStyle.h includes/agg_basics.h \
21+ includes/ft2build.h includes/agg_config.h
22+
23+# --- DO NOT MODIFY THIS LINE -- AUTO-DEPENDS PRECEDE ---
+10,
-0
1@@ -0,0 +1,10 @@
2+resource("be:decor:info") message('deco') {
3+ "name" = "FlatDecorator",
4+ "authors" = "Nhtello",
5+ "short_descr" = "FlatDecorator for Haiku v1.3",
6+ "long_descr" = "FlatDecorator: best if you use it with FlatControlLook",
7+ "lic_url" = "",
8+ "lic_name" = "MIT",
9+ "support_url" = "http://www.haiku-os.org/",
10+ float "version" = 1.3
11+};
R Alert.cpp =>
src/Alert.cpp
+0,
-0
R Bitdraw.cpp =>
src/Bitdraw.cpp
+0,
-0
R Bitype.cpp =>
src/Bitype.cpp
+0,
-0
R Blank.cpp =>
src/Blank.cpp
+0,
-0
R Drawkun.cpp =>
src/Drawkun.cpp
+0,
-0
R Pointer.cpp =>
src/Pointer.cpp
+0,
-0
R Typist.cpp =>
src/Typist.cpp
+0,
-0