xref: /haiku/docs/user/interface/Font.dox (revision 9642f7705b27e5c270c15fa526d14e1848c2c27d)
1/*
2 * Copyright 2013 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		John Scipione, jscipione@gmail.com
7 *
8 * Corresponds to:
9 *		headers/os/interface/Font.h	 hrev45178
10 *		src/kits/interface/Font.cpp	 hrev45178
11 */
12
13
14/*!
15	\file Font.h
16	\ingroup interface
17	\ingroup libbe
18	\brief BFont class definition, unicode_block class definition, and
19	       font-related struct and enum definitions.
20*/
21
22
23/*!
24	\var B_CHAR_SPACING
25
26	Position each character without adjustment. Best mode for printing.
27
28	\since BeOS R3
29*/
30
31
32/*!
33	\var B_STRING_SPACING
34
35	Optimizes the position of each character within its space. Collisions
36	are unlikely but characters may touch each other. Best mode to use when
37	the screen needs to match what appears on the printed page.
38
39	\since BeOS R3
40*/
41
42
43/*!
44	\var B_BITMAP_SPACING
45
46	The widths of the characters are chosen so that they never collide and
47	rarely touch. Best mode for drawing small amounts of text.
48
49	\since BeOS R3
50*/
51
52
53/*!
54	\var B_FIXED_SPACING
55
56	Positions characters at a constant width. Best mode for fixed-width fonts.
57
58	\since BeOS R3
59*/
60
61
62/*!
63	\enum font_direction
64	\ingroup interface
65
66	Determines the direction of the text rendered by the font,
67	left-to-right or right-to-left.
68
69	\since BeOS R3
70*/
71
72
73/*!
74	\var font_direction B_FONT_LEFT_TO_RIGHT
75
76	Left to right.
77
78	\since BeOS R3
79*/
80
81
82/*!
83	\var font_direction B_FONT_RIGHT_TO_LEFT
84
85	Right to left.
86
87	\since BeOS R3
88*/
89
90
91/*!
92	\var B_DISABLE_ANTIALIASING
93
94	Disable antialiasing. Used by BFont::Flags() and BFont::SetFlags().
95
96	\since BeOS R3
97*/
98
99
100/*!
101	\var B_FORCE_ANTIALIASING
102
103	Force antialiasing. Used by BFont::Flags() and BFont::SetFlags().
104
105	\since BeOS R3
106*/
107
108
109/*!
110	\var B_TRUNCATE_END
111
112	Truncate from the end of the string.
113
114	\since BeOS R3
115*/
116
117
118/*!
119	\var B_TRUNCATE_BEGINNING
120
121	Truncate from the beginning of the string.
122
123	\since BeOS R3
124*/
125
126
127/*!
128	\var B_TRUNCATE_MIDDLE
129
130	Truncate from the middle of the string.
131
132	\since BeOS R3
133*/
134
135
136/*!
137	\var B_TRUNCATE_SMART
138
139	Truncate while keeping each string unique.
140
141	\since BeOS R3
142*/
143
144
145/*!
146	\var B_UNICODE_UTF8
147
148	UTF-8 font encoding.
149
150	\since BeOS R3
151*/
152
153
154/*!
155	\var B_ISO_8859_1
156
157	ISO 8859-1 aka Latin 1 "Western European" font encoding.
158
159	\since BeOS R3
160*/
161
162
163/*!
164	\var B_ISO_8859_2
165
166	ISO 8859-2 aka Latin 2 "Eastern European" font encoding.
167
168	\since BeOS R3
169*/
170
171
172/*!
173	\var B_ISO_8859_3
174
175	ISO 8859-3 aka Latin 3 "South European" font encoding.
176
177	\since BeOS R3
178*/
179
180
181/*!
182	\var B_ISO_8859_4
183
184	ISO 8859-4 aka Latin 4 "Northern European" font encoding.
185
186	\since BeOS R3
187*/
188
189
190/*!
191	\var B_ISO_8859_5
192
193	ISO 8859-5 "Latin/Cyrillic" font encoding.
194
195	\since BeOS R3
196*/
197
198
199/*!
200	\var B_ISO_8859_6
201
202	ISO 8859-6 "Latin/Arabic" font encoding.
203
204	\since BeOS R3
205*/
206
207
208/*!
209	\var B_ISO_8859_7
210
211	ISO 8859-7 "Latin/Greek" font encoding.
212
213	\since BeOS R3
214*/
215
216
217/*!
218	\var B_ISO_8859_8
219
220	ISO 8859-8 "Latin/Hebrew" font encoding.
221
222	\since BeOS R3
223*/
224
225
226/*!
227	\var B_ISO_8859_9
228
229	ISO 8859-9 aka Latin 5 "Latin/Turkish" font encoding.
230
231	\since BeOS R3
232*/
233
234
235/*!
236	\var B_ISO_8859_10
237
238	ISO 8859-10 aka Latin 6 "Nordic" font encoding.
239
240	\since BeOS R3
241*/
242
243
244/*!
245	\var B_MACINTOSH_ROMAN
246
247	Macintosh Roman font encoding.
248
249	\since BeOS R3
250*/
251
252
253/*!
254	\var B_HAS_TUNED_FONT
255
256	Indicates that the font has been adjusted to look good on the screen.
257
258	\since BeOS R4
259*/
260
261
262/*!
263	\var B_IS_FIXED
264
265	Indicates that the font is non-proportional.
266
267	\since BeOS R4
268*/
269
270
271/*!
272	\var B_ITALIC_FACE
273
274	Italic font face flag.
275
276	\since BeOS R4
277*/
278
279
280/*!
281	\var B_UNDERSCORE_FACE
282
283	Underscore font face flag.
284
285	\since BeOS R4
286*/
287
288
289/*!
290	\var B_NEGATIVE_FACE
291
292	Negative font face flag.
293
294	\since BeOS R4
295*/
296
297
298/*!
299	\var B_OUTLINED_FACE
300
301	Outline font face flag.
302
303	\since BeOS R4
304*/
305
306
307/*!
308	\var B_STRIKEOUT_FACE
309
310	Strikeout font face flag.
311
312	\since BeOS R4
313*/
314
315
316/*!
317	\var B_BOLD_FACE
318
319	Bold font face flag.
320
321	\since BeOS R4
322*/
323
324
325/*!
326	\var B_REGULAR_FACE
327
328	Regular font face flag.
329
330	\since BeOS R4
331*/
332
333
334/*!
335	\var B_CONDENSED_FACE
336
337	Condensed font face flag.
338
339	\since Haiku R1
340*/
341
342
343/*!
344	\var B_LIGHT_FACE
345
346	Light font face flag.
347
348	\since Haiku R1
349*/
350
351
352/*!
353	\var B_HEAVY_FACE
354
355	Heavy font face flag.
356
357	\since Haiku R1
358*/
359
360
361/*!
362	\enum font_metric_mode
363
364	Font metric mode, screen or printing.
365
366	\since BeOS R4
367*/
368
369
370/*!
371	\var font_metric_mode B_SCREEN_METRIC
372
373	Screen font metric mode.
374
375	\since BeOS R4
376*/
377
378
379/*!
380	\var font_metric_mode B_PRINTING_METRIC
381
382	Printing font metric mode.
383
384	\since BeOS R4
385*/
386
387
388/*!
389	\enum font_file_format
390	\ingroup interface
391
392	Font file format, TrueType™ or PostScript™ Type1.
393
394	\see BFont::FileFormat()
395
396	\since BeOS R4
397*/
398
399
400/*!
401	\var font_file_format B_TRUETYPE_WINDOWS
402
403	TrueType™ font file format.
404
405	\since BeOS R4
406*/
407
408
409/*!
410	\var font_file_format B_POSTSCRIPT_TYPE1_WINDOWS
411
412	PostScript™ Type1 font file format.
413
414	\since BeOS R4
415*/
416
417
418/*!
419	\class unicode_block
420	\ingroup interface
421	\ingroup libbe
422	\brief Describes the blocks of Unicode characters supported by a font.
423
424	\see BFont::Blocks()
425
426	\since BeOS R4
427*/
428
429
430/*!
431	\fn unicode_block::unicode_block()
432	\brief Construct a \c unicode_block and set block data to 0.
433
434	You must initialize the block data before before using this object.
435
436	\since BeOS R4
437*/
438
439
440/*!
441	\fn unicode_block::unicode_block(uint64 block2, uint64 block1)
442	\brief Construct a \c unicode_block object and initialize it with the
443	       supplied Unicode block range.
444
445	\param block2 End block.
446	\param block1 Begin block.
447
448	\since BeOS R4
449*/
450
451
452/*!
453	\fn bool unicode_block::Includes(const unicode_block& block) const
454	\brief Determines if \a block is a subset of the \c unicode_block object.
455
456	\param block The Unicode block to check.
457
458	\returns Whether or not \a block is a subset of the \c unicode_block
459	         object.
460	\retval true \a block is a subset of the current \c unicode_block.
461	\retval false \a block is NOT a subset of the current \c unicode_block.
462
463	\since BeOS R4
464*/
465
466
467/*!
468	\name Operators
469*/
470
471
472//! @{
473
474
475/*!
476	\fn unicode_block unicode_block::operator&(const unicode_block& block) const
477	\brief Creates and returns a new \c unicode_block object that is the
478	       intersection of \a block and the \c unicode_block object.
479
480	\param block The Unicode block to intersect with.
481
482	\returns The intersection of \a block and the \c unicode_block object.
483
484	\since BeOS R4
485*/
486
487
488/*!
489	\fn unicode_block unicode_block::operator|(const unicode_block& block) const
490	\brief Creates and returns a new \c unicode_block object that is the union
491	       of \a block and the \c unicode_block object.
492
493	\param block The Unicode block to form a union with.
494
495	\returns The union of \a block and the \c unicode_block object.
496
497	\since BeOS R4
498*/
499
500
501/*!
502	\fn unicode_block& unicode_block::operator=(const unicode_block& block)
503	\brief Copies \a block data into the left-hand side object.
504
505	\param block The unicode block to copy from.
506
507	\returns A copy of \a block.
508
509	\since BeOS R4
510*/
511
512
513/*!
514	\fn bool unicode_block::operator==(const unicode_block& block) const
515	\brief Determines if the block object are exactly equal.
516
517	\param block The unicode block to compare against.
518
519	\returns \c true if the block object are exactly equal, \c false
520		otherwise.
521
522	\since BeOS R4
523*/
524
525
526/*!
527	\fn bool unicode_block::operator!=(const unicode_block& block) const
528	\brief Determines if the block object are not equal.
529
530	\param block The unicode block to compare against.
531
532	\returns \c true if the block object are NOT equal, \c false
533		if the block objects are exactly equal.
534
535	\since BeOS R4
536*/
537
538
539//! @}
540
541
542/*!
543	\struct edge_info
544	\ingroup interface
545	\ingroup libbe
546	\brief The distance that a character outline is inset from its escapement
547		boundaries.
548
549	Edge values, like escapements, need to be multiplied by the font size to
550	get the correct value for the font.
551
552	\see BFont::GetEdges()
553
554	\since BeOS R3
555*/
556
557
558/*!
559	\var edge_info::left
560
561	The distance that the character outline is inset from the left
562	escapement boundary.
563
564	\since BeOS R3
565*/
566
567
568/*!
569	\var edge_info::right
570
571	The distance that the character outline is inset from the right
572	escapement boundary.
573
574	\since BeOS R3
575*/
576
577
578/*!
579	\struct font_height
580	\ingroup interface
581	\ingroup libbe
582	\brief The amount of vertical space surrounding a character.
583
584	\see BFont::GetHeight()
585
586	\since BeOS R3
587*/
588
589
590/*!
591	\var font_height::ascent
592
593	The distance characters can ascend above the baseline.
594
595	\since BeOS R3
596*/
597
598
599/*!
600	\var font_height::descent
601
602	The distance characters can descend below the baseline.
603
604	\since BeOS R3
605*/
606
607
608/*!
609	\var font_height::leading
610
611	The distance between lines, descent above to ascent below.
612
613	\since BeOS R3
614*/
615
616
617/*!
618	\struct escapement_delta
619	\ingroup interface
620	\ingroup libbe
621	\brief A struct that allows you to specify extra horizontal space to surround
622		each character with.
623
624	Escapements need to be multiplied by the font size to get the correct
625	value for the font.
626
627	\see BFont::GetEscapements()
628
629	\since BeOS R3
630*/
631
632
633/*!
634	\var escapement_delta::nonspace
635
636	The amount of horizontal space to surround a visible glyph character with.
637
638	\since BeOS R3
639*/
640
641
642/*!
643	\var escapement_delta::space
644
645	The amount of horizontal space to surround a whitespace character with, for
646	example \c B_TAB or \c B_SPACE.
647
648	\since BeOS R3
649*/
650
651
652/*!
653	\struct font_cache_info
654	\ingroup interface
655	\ingroup libbe
656	\brief Font cache parameters.
657
658	\since BeOS R3
659*/
660
661
662/*!
663	\var font_cache_info::sheared_font_penalty
664
665	Sheared font penalty.
666
667	\since BeOS R3
668*/
669
670
671/*!
672	\var font_cache_info::rotated_font_penalty
673
674	Rotated font penalty.
675
676	\since BeOS R3
677*/
678
679
680/*!
681	\var font_cache_info::oversize_threshold
682
683	Oversize threshold.
684
685	\since BeOS R3
686*/
687
688
689/*!
690	\var font_cache_info::oversize_penalty
691
692	Oversize penalty.
693
694	\since BeOS R3
695*/
696
697
698/*!
699	\var font_cache_info::cache_size
700
701	Cache size.
702
703	\since BeOS R3
704*/
705
706
707/*!
708	\var font_cache_info::spacing_size_threshold
709
710	Spacing size threshold.
711
712	\since BeOS R3
713*/
714
715
716/*!
717	\struct tuned_font_info
718	\ingroup interface
719	\ingroup libbe
720	\brief Tuning information of fonts used to make it look better when
721		displayed on-screen.
722
723	\see BFont::GetTunedInfo()
724	\see BFont::CountTuned()
725
726	\since BeOS R3
727*/
728
729
730/*!
731	\var tuned_font_info::size
732
733	Font size.
734
735	\since BeOS R3
736*/
737
738
739/*!
740	\var tuned_font_info::shear
741
742	Font shear.
743
744	\since BeOS R3
745*/
746
747
748/*!
749	\var tuned_font_info::rotation
750
751	Font rotation.
752
753	\since BeOS R3
754*/
755
756
757/*!
758	\var tuned_font_info::flags
759
760	Font flags.
761
762	\since BeOS R3
763*/
764
765
766/*!
767	\var tuned_font_info::face
768
769	Font face.
770
771	\since BeOS R3
772*/
773
774
775/*!
776	\fn int32 count_font_families()
777	\brief Gets the number of installed font families
778
779	\return The number of installed font families
780
781	\since BeOS R3
782*/
783
784
785/*!
786	\fn int32 count_font_styles(font_family family)
787	\brief Gets the number of styles available for a font family.
788
789	\return The number of styles available for a font family.
790
791	\since BeOS R3
792*/
793
794
795/*!
796	\fn status_t get_font_family(int32 index, font_family *_name,
797		uint32 *_flags)
798	\brief Retrieves the family name at the specified index.
799
800	\param index Unique font identifier code.
801	\param _name font_family String to receive the name of the family.
802	\param _flags if non-<tt>NULL</tt>, the values of the flags \c IS_FIXED
803		and \c B_HAS_TUNED_FONT are returned.
804
805	\return A status code, \c B_OK on success or an error code.
806	\retval B_BAD_VALUE \a _name is \c NULL.
807	\retval B_ERROR \a index does not correspond to a font family.
808
809	\since BeOS R3
810*/
811
812
813/*!
814	\fn status_t get_font_style(font_family family, int32 index,
815		font_style *_name, uint32 *_flags)
816	\brief Retrieves the family name at the specified index.
817
818	\param family The font family.
819	\param index Unique font identifier code.
820	\param _name string to receive the name of the family.
821	\param _flags if non-<tt>NULL</tt>, the values of the flags \c IS_FIXED
822		and \c B_HAS_TUNED_FONT are returned
823
824	\return A status code, \c B_OK on success or an error code.
825	\retval B_ERROR \a index does not correspond to a font style.
826
827	\since BeOS R3
828*/
829
830
831/*!
832	\fn status_t get_font_style(font_family family, int32 index,
833		font_style *_name, uint16 *_face, uint32 *_flags)
834	\brief Retrieves the family name at the specified index.
835
836	The face value returned by this function is not very reliable. At the same
837	time, the value returned should be fairly reliable, returning the proper
838	flag for 90%-99% of font names.
839
840	\param family The font family.
841	\param index Unique font identifier code.
842	\param _name String to receive the name of the family.
843	\param _face recipient of font face value, such as \c B_REGULAR_FACE.
844	\param _flags if non-<tt>NULL</tt>, the values of the flags \c IS_FIXED
845		and \c B_HAS_TUNED_FONT are returned.
846
847	\return A status code, \c B_OK on success or an error code.
848	\retval B_ERROR \a index does not correspond to a font style.
849
850	\since BeOS R3
851*/
852
853
854/*!
855	\fn bool update_font_families(bool checkOnly)
856	\brief Updates the font families list.
857
858	\param checkOnly Parameter is ignored.
859
860	\return \c true if the font list has changed, \c false if not.
861
862	\since BeOS R3
863*/
864
865
866/*!
867	\class BFont
868	\ingroup interface
869	\ingroup libbe
870	\brief Represents a typeface including its family, style and size.
871
872	The Interface Kit provides three prebuilt BFont objects which can be used
873	but not modified.
874	- \c const BFont* \c be_plain_font A plain font used by many controls.
875	- \c const BFont* \c be_bold_font A bold font used by titles.
876	- \c const BFont* \c be_fixed_font A fixed-width font.
877
878	A BFont object does nothing on its own but is used in combination with
879	a view or control. Here is an example of creating a BFont object from a
880	system font and assigning it to a view:
881
882\code
883	BFont font(be_plain_font);
884	font.SetSize(12.0);
885	font.SetEncoding(B_ISO_8859_1);
886	view->SetFont(&font);
887\endcode
888
889	You may also create a BFont object from a view, modify it and reassign it
890	back to the view like this:
891
892\code
893	BFont font;
894	view->GetFont(&font);
895	font.SetFace(B_ITALIC_FACE);
896	font.SetSpacing(B_CHAR_SPACING);
897	myView->SetFont(&font);
898\endcode
899
900	You can change the way a font renders with the SetFamilyAndStyle(),
901	SetFamilyAndFace(), SetSize(), SetShear(), SetRotation(),
902	SetFalseBoldWidth(), SetSpacing(), SetEncoding(), SetFace(), and
903	SetFlags() methods.
904
905	More information about the space taken up by a font can be determined
906	by querying a BFont object using the following methods:
907	StringWidth(), GetStringWidths() GetEscapements(), GetEdges(),
908	GetHeight(), BoundingBox() GetBoundingBoxesAsGlyphs(),
909	GetBoundingBoxesAsString(), and GetBoundingBoxesForStrings().
910
911	You can also perform intelligent string truncation with the
912	TruncateString() and GetTruncatedStrings() methods.
913
914	\since BeOS R3
915*/
916
917
918/*!
919	\fn BFont::BFont()
920	\brief Creates a BFont object initialized to \c be_plain_font.
921
922	\see BView::GetFont()
923
924	\since BeOS R3
925*/
926
927
928/*!
929	\fn BFont::BFont(const BFont& font)
930	\brief Creates and initializes a BFont object from another BFont object.
931
932	\param font The BFont object to initialize from.
933
934	\since BeOS R3
935*/
936
937
938/*!
939	\fn BFont::BFont(const BFont* font)
940	\brief Creates and initializes a BFont object from a pointer to a BFont
941	       object.
942
943	\param font The pointer to a BFont object to initialize from.
944
945	\since BeOS R3
946*/
947
948
949/*!
950	\fn BFont::BFont(const BFont* font)
951	\brief Creates and initializes a BFont object from a pointer to a BFont
952	       object.
953
954	\param font The pointer to a BFont object to initialize from.
955
956	\since BeOS R3
957*/
958
959
960/*!
961	\fn status_t BFont::SetFamilyAndStyle(const font_family family,
962		const font_style style)
963	\brief Sets the font's family and style all at once.
964
965	\param family Font family to set.
966	\param style Font style to set.
967
968	\returns A status code, \c B_OK on success or an error code.
969	\retval B_BAD_VALUE \a family is \c NULL and \a style is \c NULL.
970	\retval B_NAME_NOT_FOUND Family or style do not exist.
971
972	\since BeOS R3
973*/
974
975
976/*!
977	\fn void BFont::SetFamilyAndStyle(uint32 code)
978	\brief Sets the font's family and style from a font identifier.
979
980	\param code Unique font identifier obtained from the server.
981
982	\since BeOS R3
983*/
984
985
986/*!
987	\fn status_t BFont::SetFamilyAndFace(const font_family family, uint16 face)
988	\brief Sets the font's family and face all at once.
989
990	\param family Font family to set.
991	\param face Font face to set.
992
993	\note To comply with the BeBook, this function will only set valid values,
994		i.e. passing a nonexistent family will cause only the face to be set.
995		Additionally, if a particular face does not exist in a family, the
996		closest match will be chosen.
997
998	\returns A status code, \c B_OK on success or an error code.
999	\retval B_ERROR Family does not exists or face has an invalid value.
1000
1001	\since BeOS R4
1002*/
1003
1004
1005/*!
1006	\fn void BFont::SetSize(float size)
1007	\brief Sets the font size.
1008
1009	\param size The point size to set the font to.
1010
1011	\since BeOS R3
1012*/
1013
1014
1015/*!
1016	\fn void BFont::SetShear(float shear)
1017	\brief Sets the angle in degrees relative to the baseline.
1018
1019	The default shear is 90.0° measured counterclockwise. The shear
1020	range is from 45.0° to 135.0°.
1021
1022	\param shear The shear in degrees to set the font to.
1023
1024	\since BeOS R3
1025*/
1026
1027
1028/*!
1029	\fn void BFont::SetRotation(float rotation)
1030	\brief Sets the font rotation from the baseline in degrees.
1031
1032	The default baseline is 0° and rotates counterclockwise. Rotation is not
1033	supported by BTextView.
1034
1035	\param rotation The rotation in degrees to set the font to.
1036
1037	\since BeOS R3
1038*/
1039
1040
1041/*!
1042	\fn void BFont::SetFalseBoldWidth(float width)
1043	\brief Sets the false bold width.
1044
1045	\param width The false bold width to set.
1046
1047	\since Haiku R1
1048*/
1049
1050
1051/*!
1052	\fn void BFont::SetSpacing(uint8 spacing)
1053	\brief Sets how characters are horizontally spaced relative to each other.
1054
1055	- \c B_CHAR_SPACING Position each character without adjustment. Best mode
1056		for printing. Characters may collide or overlap at small font sizes.
1057	- \c B_STRING_SPACING Optimizes the position of each character within its
1058		space. Collisions are unlikely but characters may touch each other.
1059		Best mode to use when the screen needs to match what appears on the
1060		printed page. Adding new characters requires the entire string to
1061		be redrawn.
1062	- \c B_BITMAP_SPACING The widths of the characters are chosen so that they
1063		never collide and rarely touch. Best mode for drawing small amounts
1064		of text. Character widths are integral values. Spacing on screen will
1065		not match spacing used by \c B_CHAR_SPACING mode for printing.
1066	- \c B_FIXED_SPACING Positions characters at a constant width. Must be
1067		used with fixed-width fonts otherwise \c B_CHAR_SPACING mode is used.
1068		All characters have an identical integral escapement.
1069
1070	\c B_STRING_SPACING and \c B_BITMAP_SPACING modes are relevant only for
1071	font sizes from 7.0pt to 18.0pt, above and below that range
1072	\c B_CHAR_SPACING produces nicer results. \c B_CHAR_SPACING is also always
1073	used for rotated or sheared text and when antialiasing is disabled.
1074
1075	\param spacing The spacing mode to set.
1076
1077	\see BView::DrawString()
1078	\see GetEscapements()
1079
1080	\since BeOS R3
1081*/
1082
1083
1084/*!
1085	\fn void BFont::SetEncoding(uint8 encoding)
1086	\brief Sets the character encoding of the font for example
1087		\c B_UNICODE_UTF8 or \c B_ISO_8859_1.
1088
1089	The following character encodings are supported:
1090	- \c B_UNICODE_UTF8
1091	- \c B_ISO_8859_1 aka Latin 1 aka "Western European".
1092	- \c B_ISO_8859_2 aka Latin 2 aka "Eastern European".
1093	- \c B_ISO_8859_3 aka Latin 3 aka "South European".
1094	- \c B_ISO_8859_4 aka Latin 4 aka "Northern European".
1095	- \c B_ISO_8859_5 aka "Latin/Cyrillic".
1096	- \c B_ISO_8859_6 aka "Latin/Arabic".
1097	- \c B_ISO_8859_7 aka "Latin/Greek".
1098	- \c B_ISO_8859_8 aka "Latin/Hebrew".
1099	- \c B_ISO_8859_9 aka Latin 5 aka "Latin/Turkish".
1100	- \c B_ISO_8859_10 aka Latin 6 aka "Nordic".
1101	- \c B_MACINTOSH_ROMAN
1102
1103	UTF-8 is the standard encoding used by classes in the Interface Kit. It
1104	is part of the Unicode® standard and allows Haiku to represent characters
1105	from all over the world while maintaining backwards compatibility with
1106	7-bit ASCII codes.
1107
1108	Each of the encodings extend the ASCII codes and differ from each other
1109	only when the highest bit is set to 1, in other words, the value is
1110	greater than 127. Furthermore each of the encodings except for UTF-8
1111	are represented by a single byte and consequently encompass a limited set
1112	of characters. Most of the encodings are in the ISO/IEC 8859 family of
1113	character codes with the notable exception of Macintosh Roman which is
1114	the standard encoding used by the classic Mac OS®.
1115
1116	If the value of the first byte of a UTF-8 character is greater than 127
1117	it indicates that the character is a multibyte character and therefore you
1118	must look at the next byte (and possibly the third byte, or rarely even
1119	forth byte) to get the whole character.
1120
1121	Setting the character encoding on a view determines how BView::DrawString()
1122	interprets the values passed to it and also how BView::KeyDown() interprets
1123	the values representing the keys that the user presses.
1124
1125	\param encoding The character encoding to set the font to.
1126
1127	\since BeOS R3
1128*/
1129
1130
1131/*!
1132	\fn void BFont::SetFace(uint16 face)
1133	\brief Sets the font face according to the flags set by \a face.
1134
1135	The following font face flags are supported:
1136	- \c B_ITALIC_FACE Characters are slanted to the right.
1137	- \c B_UNDERSCORE_FACE Characters are underlined.
1138	- \c B_NEGATIVE_FACE High and low colors are reversed when drawing
1139		characters.
1140	- \c B_OUTLINED_FACE Characters are drawn hollowed out.
1141	- \c B_STRIKEOUT_FACE A horizontal line is drawn through their middle.
1142	- \c B_BOLD_FACE Characters are bold.
1143	- \c B_REGULAR_FACE Characters are drawn normally.
1144	- \c B_CONDENSED_FACE Characters are drawn condensed. Not in BeOS 5.
1145 	- \c B_LIGHT_FACE Characters are drawn thiner than normal. Not in BeOS 5.
1146	- \c B_HEAVY_FACE Characters are drawn heavier than normal. Not in BeOS 5.
1147
1148	\param face The bitmap of font face flags to set.
1149
1150	\since BeOS R3
1151*/
1152
1153
1154/*!
1155	\fn void BFont::SetFlags(uint32 flags)
1156	\brief Sets font flags controlling antialiasing.
1157
1158	The following flags are supported:
1159	- \c B_DISABLE_ANTIALIASING Disable antialiasing.
1160	- \c B_FORCE_ANTIALIASING Force antialiasing.
1161
1162	\param flags The bitmap of flags to set.
1163
1164	\since Haiku R1
1165*/
1166
1167
1168/*!
1169	\fn void BFont::GetFamilyAndStyle(font_family* family,
1170		font_style *style) const
1171	\brief Writes out the name of the font family and/or font style.
1172
1173	This method may be called with either \a family or \a style set to
1174	\c NULL in order to get one or the other.
1175
1176	\param family A font_family pointer to be filled out.
1177	\param style  A font_style pointer to be filled out.
1178
1179	\since BeOS R3
1180*/
1181
1182
1183/*!
1184	\fn uint32 BFont::FamilyAndStyle() const
1185	\brief Gets the code of the font family and style combination.
1186
1187	\returns The family and style combination encoded as a unique integer.
1188
1189	\see SetFamilyAndStyle(uint32 code)
1190
1191	\since BeOS R3
1192*/
1193
1194
1195/*!
1196	\fn float BFont::Size() const
1197	\brief Gets the font size.
1198
1199	\returns The font size in points.
1200
1201	\see SetSize()
1202
1203	\since BeOS R3
1204*/
1205
1206
1207/*!
1208	\fn float BFont::Shear() const
1209	\brief Gets the font shear.
1210
1211	\returns The font shear as an angle from 45.0° to 135.0°.
1212
1213	\see SetShear()
1214
1215	\since BeOS R3
1216*/
1217
1218
1219/*!
1220	\fn float BFont::Rotation() const
1221	\brief Gets the font rotation.
1222
1223	\returns The font rotation as an angle in degrees.
1224
1225	\see SetRotation()
1226
1227	\since BeOS R3
1228*/
1229
1230
1231/*!
1232	\fn float BFont::FalseBoldWidth() const
1233	\brief Gets the width of the font as if it were bold.
1234
1235	\returns The font width of the bold font variety.
1236
1237	\see SetFalseBoldWidth()
1238
1239	\since Haiku R1
1240*/
1241
1242
1243/*!
1244	\fn uint8 BFont::Spacing() const
1245	\brief Gets the spacing constant.
1246
1247	\returns The spacing constant.
1248
1249	\see SetSpacing()
1250
1251	\since BeOS R3
1252*/
1253
1254
1255/*!
1256	\fn uint8 BFont::Encoding() const
1257	\brief Gets the character encoding constant.
1258
1259	\returns The character encoding constant.
1260
1261	\see SetEncoding()
1262
1263	\since BeOS R3
1264*/
1265
1266
1267/*!
1268	\fn uint16 BFont::Face() const
1269	\brief Gets the font face flags bitmap.
1270
1271	\returns The font face flags bitmap.
1272
1273	\see SetFace()
1274
1275	\since BeOS R3
1276*/
1277
1278
1279/*!
1280	\fn uint32 BFont::Flags() const
1281	\brief Gets the antialiasing flags.
1282
1283	\returns The antialiasing flags.
1284
1285	\see SetFlags()
1286
1287	\since BeOS R3
1288*/
1289
1290
1291/*!
1292	\fn font_direction BFont::Direction() const
1293	\brief Gets the font direction, left-to-right or right-to left.
1294
1295	\returns The font direction.
1296
1297	\since BeOS R3
1298*/
1299
1300
1301/*!
1302	\fn bool BFont::IsFixed() const
1303	\brief Gets whether or not the font is fixed width.
1304
1305	\returns \c true if the font is fixed width, \c false otherwise.
1306
1307	\since BeOS R4
1308*/
1309
1310
1311/*!
1312	\fn bool BFont::IsFullAndHalfFixed() const
1313	\brief Returns whether or not the font is fixed-width and contains both
1314		full and half-width characters.
1315
1316	\note This was left unimplemented as of R5. It is a way to work with both
1317	      Kanji and Roman characters in the same fixed-width font.
1318
1319	\since BeOS R4
1320*/
1321
1322
1323/*!
1324	\fn BRect BFont::BoundingBox() const
1325	\brief Gets a BRect that encloses the font text.
1326
1327	\returns A BRect that encloses the font text.
1328
1329	\since BeOS R4
1330*/
1331
1332
1333/*!
1334	\fn unicode_block BFont::Blocks() const
1335	\brief Gets a \c unicode_block object that identifies the Unicode blocks
1336	       supported by this font face and family.
1337
1338	\attention Currently unimplemented, returns an empty \a unicode_block
1339	           object.
1340
1341	\returns A \c unicode_block object containing supported Unicode blocks.
1342
1343	\since BeOS R4
1344*/
1345
1346
1347/*!
1348	\fn font_file_format BFont::FileFormat() const
1349	\brief Gets whether the font is a TrueType™ or PostScript™ Type1 font.
1350
1351	\returns A \c font_file_format struct containing the font file format.
1352
1353	\since BeOS R4
1354*/
1355
1356
1357/*!
1358	\fn int32 BFont::CountTuned() const
1359	\brief Gets the number of tuned fonts for the font family and style.
1360
1361	\returns The number of tuned fonts.
1362
1363	\since BeOS R3
1364*/
1365
1366
1367/*!
1368	\fn void BFont::GetTunedInfo(int32 index, tuned_font_info *info) const
1369	\brief Writes information about the tuned font at \a index into \a info.
1370
1371	The index begins at 0 and counts tuned fonts for current font family and
1372	style only.
1373
1374	\param index The index of desired tuned font.
1375	\param info The \a turned_font_info struct to be filled out.
1376
1377	\since BeOS R3
1378*/
1379
1380
1381/*!
1382	\fn void BFont::TruncateString(BString *inOut, uint32 mode,
1383		float width) const
1384	\brief Truncates \a inOut to be no longer than \a width using the
1385	       supplied truncation \a mode.
1386
1387	The following truncation modes are supported:
1388	- \c B_TRUNCATE_BEGINNING Truncate from the beginning of the string.
1389	- \c B_TRUNCATE_MIDDLE Truncate from the middle of the string.
1390	- \c B_TRUNCATE_END Truncate from the end of the string.
1391	- \c B_TRUNCATE_SMART Truncate from anywhere, but do so so that each
1392		string is made unique after being truncated.
1393
1394	\param inOut The BString to truncate.
1395	\param mode Truncation mode to use.
1396	\param width The maximum width to truncate to.
1397
1398	\since BeOS R5
1399*/
1400
1401
1402/*!
1403	\fn void BFont::GetTruncatedStrings(const char *stringArray[],
1404		int32 numStrings, uint32 mode, float width,
1405		BString resultArray[]) const
1406	\brief Write truncated BString objects to \a resultArray given source
1407	       BString objects in \a stringArray.
1408
1409	The following truncation modes are supported:
1410	- \c B_TRUNCATE_BEGINNING Truncate from the beginning of the string.
1411	- \c B_TRUNCATE_MIDDLE Truncate from the middle of the string.
1412	- \c B_TRUNCATE_END Truncate from the end of the string.
1413	- \c B_TRUNCATE_SMART Truncate from anywhere, but do so so that each
1414	     string is made unique after being truncated.
1415
1416	\param stringArray The source string array.
1417	\param numStrings The number of strings in \a stringArray.
1418	\param mode Truncation mode to use.
1419	\param width The maximum width to truncate to.
1420	\param resultArray The destination string array.
1421
1422	\since BeOS R5
1423*/
1424
1425
1426/*!
1427	\fn void BFont::GetTruncatedStrings(const char *stringArray[],
1428		int32 numStrings, uint32 mode, float width, char *resultArray[]) const
1429	\brief Write truncated strings to \a resultArray given source
1430	       BString objects in \a stringArray.
1431
1432	\a resultArray is an array of pointers to string buffers which should be
1433	allocated ahead of time and should be at least 3 bytes longer than the
1434	matching input string. The 3 extra bytes provide enough room for the
1435	truncated output given that GetTruncatedStrings() truncates only a
1436	single-byte character from the input string and replaces it with an
1437	ellipsis character (which takes three bytes for the UTF-8 encoding),
1438	and adds a \c NUL-terminator.
1439
1440	The following truncation modes are supported:
1441	- \c B_TRUNCATE_BEGINNING Truncate from the beginning of the string.
1442	- \c B_TRUNCATE_MIDDLE Truncate from the middle of the string.
1443	- \c B_TRUNCATE_END Truncate from the end of the string.
1444	- \c B_TRUNCATE_SMART Truncate from anywhere, but do so so that each
1445	     string is made unique after being truncated.
1446
1447	\param stringArray The source string array.
1448	\param numStrings The number of strings in \a stringArray.
1449	\param mode Truncation mode to use.
1450	\param width The maximum width to truncate to.
1451	\param resultArray The destination string array.
1452
1453	\since BeOS R5
1454*/
1455
1456
1457/*!
1458	\fn float BFont::StringWidth(const char *string) const
1459	\brief Determines the amount of space required to draw \a string in the
1460	       current font.
1461
1462	\param string The source string.
1463
1464	\returns The width required to draw the string.
1465
1466	\since BeOS R3
1467*/
1468
1469
1470/*!
1471	\fn float BFont::StringWidth(const char *string, int32 length) const
1472	\brief Determines the amount of space required to draw \a string in the
1473	       current font up to \a length characters.
1474
1475	\param string The source string.
1476	\param length The number of characters in \a string to consider.
1477
1478	\returns The width required to draw the string.
1479
1480	\since BeOS R3
1481*/
1482
1483
1484/*!
1485	\fn void BFont::GetStringWidths(const char *stringArray[],
1486		const int32 lengthArray[], int32 numStrings, float widthArray[]) const
1487	\brief Determines the amount of space required to draw each string in
1488	       \a stringArray and writes the result in \a widthArray.
1489
1490	\param stringArray The source string array.
1491	\param lengthArray The number of characters to consider for each string in
1492		\a stringArray
1493	\param numStrings The number of strings in \a stringArray.
1494	\param widthArray The destination array to put the widths required to draw
1495		each string.
1496
1497	\since BeOS R3
1498*/
1499
1500
1501/*!
1502	\fn void BFont::GetEscapements(const char charArray[], int32 numChars,
1503		float escapementArray[]) const
1504	\brief Determines the escapements for each char in \a charArray and writes
1505		the result in \a escapementArray.
1506
1507	\param charArray The source character array.
1508	\param numChars The number of characters to consider in \a charArray.
1509	\param escapementArray The destination array to put the escapements.
1510
1511	\since BeOS R3
1512*/
1513
1514
1515/*!
1516	\fn void BFont::GetEscapements(const char charArray[], int32 numChars,
1517		escapement_delta* delta, float escapementArray[]) const
1518	\brief Determines the escapements for each char in \a charArray and writes
1519		the result in \a escapementArray with consideration to the horizontal
1520		space provided by the escapement \a delta.
1521
1522	The escapement_delta structure contains the following values:
1523	- \c nonspace The amount of horizontal space to surround a visible glyph
1524		character with.
1525	- \c space The amount of horizontal space to surround a whitespace character
1526		with, for example \c B_TAB or \c B_SPACE.
1527
1528	\param charArray The source character array.
1529	\param numChars The number of characters to consider in \a charArray.
1530	\param delta The escapement_delta structure to use.
1531	\param escapementArray The destination array to put the escapements.
1532
1533	\since BeOS R3
1534*/
1535
1536
1537/*!
1538	\fn void BFont::GetEscapements(const char charArray[], int32 numChars,
1539		escapement_delta *delta, BPoint escapementArray[]) const
1540	\brief Determines the escapements for each char in \a charArray and writes
1541		the result in \a escapementArray as an array of BPoint objects
1542		with consideration to the horizontal space provided by the escapement
1543		\a delta.
1544
1545	The escapement_delta structure contains the following values:
1546	- \c nonspace The amount of horizontal space to surround a visible glyph
1547		character with.
1548	- \c space The amount of horizontal space to surround a whitespace character
1549		with, for example \c B_TAB or \c B_SPACE.
1550
1551	\param charArray The source character array.
1552	\param numChars The number of characters to consider in \a charArray.
1553	\param delta The escapement_delta structure to use.
1554	\param escapementArray The destination array of escapements as BPoint
1555		objects.
1556
1557	\since BeOS R4
1558*/
1559
1560
1561/*!
1562	\fn void BFont::GetEscapements(const char charArray[], int32 numChars,
1563		escapement_delta *delta, BPoint escapementArray[],
1564		BPoint offsetArray[]) const
1565	\brief Determines the escapements for each char in \a charArray and writes
1566		the result in \a escapementArray as an array of BPoint objects
1567		with consideration to the horizontal space provided by the escapement
1568		\a delta and writes the offsets to \a offsetArray.
1569
1570	The escapement_delta structure contains the following values:
1571	- \c nonspace The amount of horizontal space to surround a visible glyph
1572		character with.
1573	- \c space The amount of horizontal space to surround a whitespace character
1574		with, for example \c B_TAB or \c B_SPACE.
1575
1576	\param charArray The source character array.
1577	\param numChars The number of characters to consider in \a charArray.
1578	\param delta The escapement_delta structure to use.
1579	\param escapementArray The destination array of escapements as BPoint
1580		objects.
1581	\param offsetArray The destination array of offsets as BPoint objects.
1582
1583	\since BeOS R4
1584*/
1585
1586
1587/*!
1588	\fn void BFont::GetEdges(const char charArray[], int32 numChars,
1589		edge_info edgeArray[]) const
1590	\brief Determines the edge information for each character in \a charArray
1591		and writes the result in \a edgeArray.
1592
1593	The \c edge_info struct contains the following values:
1594	- \c left The distance that the character outline is inset from the left
1595		escapement boundary.
1596	- \c right  The distance that the character outline is inset from the
1597		right escapement boundary.
1598
1599	\param charArray The source character array.
1600	\param numChars The number of characters to consider in \a charArray.
1601	\param edgeArray The destination array of \c edge_info structs.
1602
1603	\since BeOS R3
1604*/
1605
1606
1607/*!
1608	\fn void BFont::GetHeight(font_height *_height) const
1609	\brief Fills out the \c font_height struct with the amount of vertical
1610		space surrounding a character.
1611
1612	The \c font_height struct contains the following values:
1613	- \c ascent The distance characters can ascend above the baseline.
1614	- \c descent The distance characters can descend below the baseline.
1615	- \c leading The distance between lines, descent above to ascent below.
1616
1617	\param _height The \c font_height struct to fill out.
1618
1619	\since BeOS R3
1620*/
1621
1622
1623/*!
1624	\fn void BFont::GetBoundingBoxesAsGlyphs(const char charArray[],
1625		int32 numChars, font_metric_mode mode, BRect boundingBoxArray[]) const
1626	\brief Writes an array of BRect objects to \a boundingBoxArray
1627		representing the bounding rectangles of each character in
1628		\a charArray.
1629
1630	Each BRect object corresponds to the glyph of one character.
1631
1632	The \c font_metric_mode should contain one of the following values:
1633	- \c B_SCREEN_METRIC The bounding boxes should use the screen metric.
1634	- \c B_PRINTING_METRIC The bounding boxes should use the print metric.
1635
1636	\param charArray The source character array.
1637	\param numChars The number of characters to consider in \a charArray.
1638	\param mode The \c font_metric_mode to use, screen or printing.
1639	\param boundingBoxArray The destination array of BRect bounding boxes.
1640
1641	\since BeOS R4
1642*/
1643
1644
1645/*!
1646	\fn void BFont::GetBoundingBoxesAsString(const char charArray[],
1647		int32 numChars, font_metric_mode mode, escapement_delta *delta,
1648		BRect boundingBoxArray[]) const
1649	\brief Writes an array of BRect objects to \a boundingBoxArray representing
1650		the bounding rectangles of each character in \a charArray with
1651		consideration to the horizontal space provided by the escapement
1652		\a delta.
1653
1654	Each BRect object corresponds to the glyph of one character.
1655
1656	The \c font_metric_mode should contain one of the following values:
1657	- \c B_SCREEN_METRIC The bounding boxes should use the screen metric.
1658	- \c B_PRINTING_METRIC The bounding boxes should use the print metric.
1659
1660	The provided escapement \a delta is applied as part of the bounding box
1661	calculations. This lets you specify a character spacing is looser or
1662	tighter than normal.
1663
1664	The escapement_delta structure contains the following values:
1665	- \c nonspace The amount of horizontal space to surround a visible glyph
1666		character with.
1667	- \c space The amount of horizontal space to surround a whitespace character
1668		with, for example \c B_TAB or \c B_SPACE.
1669
1670	\param charArray The source character array.
1671	\param numChars The number of characters to consider in \a charArray.
1672	\param mode The \c font_metric_mode to use, screen or printing.
1673	\param delta The escapement_delta structure to use.
1674	\param boundingBoxArray The destination array of BRect bounding boxes.
1675
1676	\since BeOS R4
1677*/
1678
1679
1680/*!
1681	\fn void BFont::GetBoundingBoxesForStrings(const char *stringArray[],
1682		int32 numStrings, font_metric_mode mode, escapement_delta deltas[],
1683		BRect boundingBoxArray[]) const
1684	\brief Writes an array of BRect objects to \a boundingBoxArray representing
1685		the bounding rectangles of each string in \a stringArray with
1686		consideration to the horizontal space provided by the escapement
1687		\a deltas.
1688
1689	Each BRect object corresponds to the bounding box of the entire string.
1690
1691	The \c font_metric_mode should contain one of the following values:
1692	- \c B_SCREEN_METRIC The bounding boxes should use the screen metric.
1693	- \c B_PRINTING_METRIC The bounding boxes should use the print metric.
1694
1695	The provided escapement \a deltas are applied as part of the bounding box
1696	calculations. This lets you specify a character spacing is looser or tighter
1697	than normal.
1698
1699	The escapement_delta structure contains the following values:
1700	- \c nonspace The amount of horizontal space to surround a visible glyph
1701		character with.
1702	- \c space The amount of horizontal space to surround a whitespace character
1703		with, for example \c B_TAB or \c B_SPACE.
1704
1705	\param stringArray The source string array.
1706	\param numStrings The number of strings to consider in \a stringArray.
1707	\param mode The \c font_metric_mode to use, screen or printing.
1708	\param deltas The array of escapement_delta structures to use.
1709	\param boundingBoxArray The destination array of BRect bounding boxes.
1710
1711	\since BeOS R4
1712*/
1713
1714
1715/*!
1716	\fn void BFont::GetGlyphShapes(const char charArray[], int32 numChars,
1717		BShape *glyphShapeArray[]) const
1718	\brief Writes an array of BShape objects to \a glyphShapeArray
1719		representing the glyph shapes of each character in
1720		\a charArray.
1721
1722	Each BShape object corresponds to the glyph of one character.
1723
1724	\param charArray The source character array.
1725	\param numChars The number of characters to consider in \a charArray.
1726	\param glyphShapeArray The destination array of BShape glyphs.
1727
1728	\since BeOS R4
1729*/
1730
1731
1732/*!
1733	\fn void BFont::GetHasGlyphs(const char charArray[], int32 numChars,
1734		bool hasArray[]) const
1735	\brief Fills out \a hasArray with whether or not each characters in
1736		\a charArray has a glyph for the font.
1737
1738	\c true is written in \a hasArray if the character has a glyph in the
1739	current font and \c false is written in \a hasArray if the character
1740	does NOT have a glyph in the current font.
1741
1742	\param charArray The source character array.
1743	\param numChars The number of characters to consider in \a charArray.
1744	\param hasArray The destination array of booleans.
1745
1746	\since BeOS R4
1747*/
1748
1749
1750/*!
1751	\fn BFont& BFont::operator=(const BFont &font)
1752	\brief Assignment overload method.
1753
1754	\param font The BFont object to assign from.
1755
1756	\since BeOS R3
1757*/
1758
1759
1760/*!
1761	\fn bool BFont::operator==(const BFont &font) const
1762	\brief Equality comparison overload method.
1763
1764	\param font The BFont object to compare the current font to.
1765
1766	\returns \c true if the fonts objects are identical, \c false otherwise.
1767
1768	\since BeOS R3
1769*/
1770
1771
1772/*!
1773	\fn bool BFont::operator!=(const BFont &font) const
1774	\brief Inequality comparison overload method.
1775
1776	\param font The BFont object to compare the current font to.
1777
1778	\returns \c true if the fonts objects are NOT identical, \c true
1779		otherwise.
1780
1781	\since BeOS R3
1782*/
1783
1784
1785/*!
1786	\fn void BFont::PrintToStream() const
1787	\brief Writes information about the font to \c stdout.
1788
1789	printf("BFont { %s (%d), %s (%d) 0x%x %f/%f %fpt (%f %f %f), %d }\n",
1790		family, fFamilyID, style, fStyleID, fFace, fShear, fRotation, fSize,
1791		fHeight.ascent, fHeight.descent, fHeight.leading, fEncoding);
1792
1793	\since BeOS R3
1794*/
1795