File size: 34,875 Bytes
9375c9a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
<html><!-- Created using the cpp_pretty_printer from the dlib C++ library. See http://dlib.net for updates. --><head><title>dlib C++ Library - fonts_abstract.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2005 Davis E. King ([email protected]), Nils Labugt, Keita Mochizuki
</font><font color='#009900'>// License: Boost Software License See LICENSE.txt for the full license.
</font><font color='#0000FF'>#undef</font> DLIB_FONTs_ABSTRACT_
<font color='#0000FF'>#ifdef</font> DLIB_FONTs_ABSTRACT_
<font color='#0000FF'>#include</font> <font color='#5555FF'><</font>string<font color='#5555FF'>></font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../serialize.h.html'>../serialize.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../unicode.h.html'>../unicode.h</a>"
<font color='#0000FF'>#include</font> <font color='#5555FF'><</font>iostream<font color='#5555FF'>></font>
<font color='#0000FF'>namespace</font> dlib
<b>{</b>
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>class</font> <b><a name='letter'></a>letter</b>
<b>{</b>
<font color='#009900'>/*!
WHAT THIS OBJECT REPRESENTS
This object represents a letter in a font. It tells you the nominal
width of the letter and which pixels form the letter.
THREAD SAFETY
const versions of this object are thread safe but if you are going to
be modifying it then you must serialize access to it.
!*/</font>
<font color='#0000FF'>public</font>:
<font color='#0000FF'>struct</font> <b><a name='point'></a>point</b>
<b>{</b>
<font color='#009900'>/*!
WHAT THIS OBJECT REPRESENTS
This object represents one of the pixels of a letter.
The origin (i.e. (0,0)) of the coordinate plane is at the left
side of the letter's baseline. Also note that y is negative when
above the baseline and positive below (it is zero on the baseline
itself).
The x value is positive going to the right and negative to the left.
The meaning of a negative x value is that any points with a negative
x value will overlap with the preceding letter.
!*/</font>
<b><a name='point'></a>point</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- This constructor does nothing. The value of x and y
are undefined after its execution.
!*/</font>
<b><a name='point'></a>point</b> <font face='Lucida Console'>(</font>
<font color='#0000FF'><u>signed</u></font> <font color='#0000FF'><u>char</u></font> x_,
<font color='#0000FF'><u>signed</u></font> <font color='#0000FF'><u>char</u></font> y_
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- #x == x_
- #y == y_
!*/</font>
<font color='#0000FF'><u>signed</u></font> <font color='#0000FF'><u>char</u></font> x;
<font color='#0000FF'><u>signed</u></font> <font color='#0000FF'><u>char</u></font> y;
<b>}</b>;
<font color='#009900'>// ---------------------------------
</font>
<b><a name='letter'></a>letter</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- #width() == 0
- #num_of_points() == 0
!*/</font>
<b><a name='letter'></a>letter</b> <font face='Lucida Console'>(</font>
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> width_,
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> point_count
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- #width() == width_
- #num_of_points() == point_count
!*/</font>
~<b><a name='letter'></a>letter</b><font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- any resources used by *this have been freed
!*/</font>
<font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> <b><a name='width'></a>width</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
<font color='#009900'>/*!
ensures
- returns the width reserved for this letter in pixels. This is the
number of pixels that are reserved for this letter between adjoining
letters. It isn't necessarily the width of the actual letter itself.
(for example, you can make a letter with a width less than how wide it
actually is so that it overlaps with its neighbor letters.)
!*/</font>
<font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> <b><a name='num_of_points'></a>num_of_points</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
<font color='#009900'>/*!
ensures
- returns the number of pixels that make up this letter.
!*/</font>
point<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b>[] <font face='Lucida Console'>(</font>
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> i
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
requires
- i < num_of_points()
ensures
- returns a non-const reference to the ith point in this letter.
!*/</font>
<font color='#0000FF'>const</font> point<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b>[] <font face='Lucida Console'>(</font>
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> i
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
<font color='#009900'>/*!
requires
- i < num_of_points()
ensures
- returns a const reference to the ith point in this letter.
!*/</font>
<font color='#0000FF'><u>void</u></font> <b><a name='swap'></a>swap</b> <font face='Lucida Console'>(</font>
letter<font color='#5555FF'>&</font> item
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- swaps *this with item
!*/</font>
<font color='#0000FF'>private</font>:
<font color='#009900'>// restricted functions
</font> <b><a name='letter'></a>letter</b><font face='Lucida Console'>(</font>letter<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// copy constructor
</font> letter<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>letter<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// assignment operator
</font> <b>}</b>;
<font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font> <b><a name='swap'></a>swap</b> <font face='Lucida Console'>(</font>
letter<font color='#5555FF'>&</font> a,
letter<font color='#5555FF'>&</font> b
<font face='Lucida Console'>)</font> <b>{</b> a.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>b<font face='Lucida Console'>)</font>; <b>}</b>
<font color='#009900'>/*!
provides a global swap
!*/</font>
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'><u>void</u></font> <b><a name='serialize'></a>serialize</b> <font face='Lucida Console'>(</font>
<font color='#0000FF'>const</font> letter<font color='#5555FF'>&</font> item,
std::ostream<font color='#5555FF'>&</font> out
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
provides serialization support for letter objects
!*/</font>
<font color='#0000FF'><u>void</u></font> <b><a name='deserialize'></a>deserialize</b> <font face='Lucida Console'>(</font>
letter<font color='#5555FF'>&</font> item,
std::istream<font color='#5555FF'>&</font> in
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
provides deserialization support for letter objects
!*/</font>
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>class</font> <b><a name='font'></a>font</b>
<b>{</b>
<font color='#009900'>/*!
WHAT THIS OBJECT REPRESENTS
This object defines an interface for a font type. It provides metrics
for the font and functions to help you draw strings on a canvas object.
THREAD SAFETY
All the functions in this class are thread safe.
!*/</font>
<font color='#0000FF'>public</font>:
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>bool</u></font> <b><a name='has_character'></a>has_character</b> <font face='Lucida Console'>(</font>
unichar ch
<font face='Lucida Console'>)</font><font color='#0000FF'>const</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
<font color='#009900'>/*!
ensures
- if (this font has a glyph for the given character) then
- returns true
- else
- returns false
!*/</font>
<font color='#0000FF'><u>bool</u></font> <b><a name='has_character'></a>has_character</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font> ch<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#0000FF'>this</font><font color='#5555FF'>-</font><font color='#5555FF'>></font><font color='#BB00BB'>has_character</font><font face='Lucida Console'>(</font>zero_extend_cast<font color='#5555FF'><</font>unichar<font color='#5555FF'>></font><font face='Lucida Console'>(</font>ch<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; <b>}</b>
<font color='#0000FF'><u>bool</u></font> <b><a name='has_character'></a>has_character</b><font face='Lucida Console'>(</font><font color='#0000FF'><u>wchar_t</u></font> ch<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#0000FF'>this</font><font color='#5555FF'>-</font><font color='#5555FF'>></font><font color='#BB00BB'>has_character</font><font face='Lucida Console'>(</font>zero_extend_cast<font color='#5555FF'><</font>unichar<font color='#5555FF'>></font><font face='Lucida Console'>(</font>ch<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>; <b>}</b>
<font color='#009900'>/* Cast char and wchar_t to unichar correctly when char or wchar_t is a signed type */</font>
<font color='#0000FF'>virtual</font> <font color='#0000FF'>const</font> letter<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b>[] <font face='Lucida Console'>(</font>
unichar ch
<font face='Lucida Console'>)</font><font color='#0000FF'>const</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
<font color='#009900'>/*!
ensures
- if (has_character(ch) == true) then
- returns a letter object that tells you how to draw this character.
- else
- returns some default glyph for characters that aren't in this font.
!*/</font>
<font color='#0000FF'>const</font> letter<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b>[] <font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font> ch<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font>[zero_extend_cast<font color='#5555FF'><</font>unichar<font color='#5555FF'>></font><font face='Lucida Console'>(</font>ch<font face='Lucida Console'>)</font>]; <b>}</b>;
<font color='#0000FF'>const</font> letter<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b>[] <font face='Lucida Console'>(</font><font color='#0000FF'><u>wchar_t</u></font> ch<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font>[zero_extend_cast<font color='#5555FF'><</font>unichar<font color='#5555FF'>></font><font face='Lucida Console'>(</font>ch<font face='Lucida Console'>)</font>]; <b>}</b>;
<font color='#009900'>/* Cast char and wchar_t to unichar correctly when char or wchar_t is a signed type */</font>
<font color='#0000FF'>virtual</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='height'></a>height</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#009900'>/*!
ensures
- returns the height in pixels of the tallest letter in the font
!*/</font>
<font color='#0000FF'>virtual</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='ascender'></a>ascender</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#009900'>/*!
ensures
- returns the height() minus the number of pixels below the baseline used
by the letter that hangs the lowest below the baseline.
!*/</font>
<font color='#0000FF'>virtual</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='left_overflow'></a>left_overflow</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#009900'>/*!
ensures
- returns how far outside and to the left of its width a letter
from this font may set pixels. (i.e. how many extra pixels to its
left may a font use)
!*/</font>
<font color='#0000FF'>virtual</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='right_overflow'></a>right_overflow</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#009900'>/*!
ensures
- returns how far outside and to the right of its width a letter
from this font may set pixels. (i.e. how many extra pixels to its
right may a font use)
!*/</font>
<font color='#0000FF'>template</font> <font color='#5555FF'><</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> traits, <font color='#0000FF'>typename</font> alloc<font color='#5555FF'>></font>
<font color='#0000FF'><u>void</u></font> <b><a name='compute_size'></a>compute_size</b> <font face='Lucida Console'>(</font>
<font color='#0000FF'>const</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font><font color='#5555FF'>&</font> str,
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&</font> width,
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&</font> height,
<font color='#0000FF'>typename</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::size_type first <font color='#5555FF'>=</font> <font color='#979000'>0</font>,
<font color='#0000FF'>typename</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::size_type last <font color='#5555FF'>=</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::npos
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
<font color='#009900'>/*!
requires
- if (last != std::basic_string<T,traits,alloc>::npos) then
- first <= last
- last < str.size()
ensures
- all characters in str with an index < first are ignored by this
function.
- if (last != std::basic_string<T,traits,alloc>::npos) then
- all characters in str with an index > last are ignored by
this function.
- if (str.size() == 0) then
- #width == 0
- #height == 0
- else
- #width == sum of the widths of the characters in the widest
line in str + left_overflow() + right_overflow().
- #height == (count(str.begin(),str.end(),'\n')+1)*height()
!*/</font>
<font color='#0000FF'>template</font> <font color='#5555FF'><</font><font color='#0000FF'>typename</font> C, <font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> traits, <font color='#0000FF'>typename</font> alloc, <font color='#0000FF'>typename</font> pixel_type<font color='#5555FF'>></font>
<font color='#0000FF'><u>void</u></font> <b><a name='draw_string'></a>draw_string</b> <font face='Lucida Console'>(</font>
<font color='#0000FF'>const</font> C<font color='#5555FF'>&</font> c,
<font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&</font> rect,
<font color='#0000FF'>const</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font><font color='#5555FF'>&</font> str,
<font color='#0000FF'>const</font> pixel_type<font color='#5555FF'>&</font> color <font color='#5555FF'>=</font> <font color='#BB00BB'>rgb_pixel</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>,
<font color='#0000FF'>typename</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::size_type first <font color='#5555FF'>=</font> <font color='#979000'>0</font>,
<font color='#0000FF'>typename</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::size_type last <font color='#5555FF'>=</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::npos,
<font color='#0000FF'>const</font> rectangle area <font color='#5555FF'>=</font> <font color='#BB00BB'>rectangle</font><font face='Lucida Console'>(</font><font color='#5555FF'>-</font>infinity,<font color='#5555FF'>-</font>infinity,infinity,infinity<font face='Lucida Console'>)</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
<font color='#009900'>/*!
requires
- C is a dlib::canvas or an object with a compatible interface.
- if (last != std::basic_string<T,traits,alloc>::npos) then
- first <= last
- last < str.size()
ensures
- all characters in str with an index < first are ignored by this
function.
- if (last != std::basic_string<T,traits,alloc>::npos) then
- all characters in str with an index > last are ignored by
this function.
- if (str.size() == 0) then
- does nothing
- else
- draws str on the given canvas at the position defined by rect.
Also uses the given pixel colors for the font color.
- If the string is too big to fit in rect then the right and
bottom sides of it will be clipped to make it fit.
- only the part of the string that is contained inside the area
rectangle will be drawn
!*/</font>
<font color='#0000FF'>template</font> <font color='#5555FF'><</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> traits, <font color='#0000FF'>typename</font> alloc<font color='#5555FF'>></font>
<font color='#0000FF'>const</font> rectangle <b><a name='compute_cursor_rect'></a>compute_cursor_rect</b> <font face='Lucida Console'>(</font>
<font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&</font> rect,
<font color='#0000FF'>const</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font><font color='#5555FF'>&</font> str,
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> index,
<font color='#0000FF'>typename</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::size_type first <font color='#5555FF'>=</font> <font color='#979000'>0</font>,
<font color='#0000FF'>typename</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::size_type last <font color='#5555FF'>=</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::npos
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
<font color='#009900'>/*!
requires
- if (last != std::basic_string<T,traits,alloc>::npos) then
- first <= last
- last < str.size()
ensures
- the returned rectangle has a width of 1 and a
height of this->height().
- computes the location of the cursor that would sit just before
the character str[index] if str were drawn on the screen by
draw_string(rect,str,...,first,last). The cursor location is
returned in the form of a rectangle.
- if (index < first) then
- the returned cursor will be just before the character str[first].
- if (last != std::basic_string<T,traits,alloc>::npos && index > last) then
- the returned cursor will be just after the character str[last]
- if (str.size() == 0) then
- the returned cursor will be just at the start of the rectangle where
str would be drawn if it wasn't empty.
- if (index > str.size()-1) then
- the returned cursor will be just after the character str[str.size()-1]
!*/</font>
<font color='#0000FF'>template</font> <font color='#5555FF'><</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> traits, <font color='#0000FF'>typename</font> alloc<font color='#5555FF'>></font>
<font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='compute_cursor_pos'></a>compute_cursor_pos</b> <font face='Lucida Console'>(</font>
<font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&</font> rect,
<font color='#0000FF'>const</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font><font color='#5555FF'>&</font> str,
<font color='#0000FF'><u>long</u></font> x,
<font color='#0000FF'><u>long</u></font> y,
<font color='#0000FF'>typename</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::size_type first <font color='#5555FF'>=</font> <font color='#979000'>0</font>,
<font color='#0000FF'>typename</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::size_type last <font color='#5555FF'>=</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::npos
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
<font color='#009900'>/*!
requires
- if (last != std::basic_string<T,traits,alloc>::npos) then
- first <= last
- last < str.size()
ensures
- returns a number idx that has the following properties:
- if (first < str.size()) then
- first <= idx
- else
- idx == str.size()
- if (last != std::basic_string<T,traits,alloc>::npos) then
- idx <= last + 1
- compute_cursor_rect(rect,str,idx,first,last) == the cursor
position that is closest to the pixel (x,y)
!*/</font>
<font color='#0000FF'>private</font>:
<font color='#009900'>// restricted functions
</font> <b><a name='font'></a>font</b><font face='Lucida Console'>(</font>font<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// copy constructor
</font> font<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>font<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// assignment operator
</font> <b>}</b>;
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>class</font> <b><a name='default_font'></a>default_font</b> : <font color='#0000FF'>public</font> font
<b>{</b>
<font color='#009900'>/*!
WHAT THIS OBJECT REPRESENTS
This is an implementation of the Helvetica 12 point font.
THREAD SAFETY
It is safe to call get_font() and access the returned font from any
thread and no synchronization is needed as long as it is called
after the main() function has been entered.
!*/</font>
<font color='#0000FF'>public</font>:
<font color='#0000FF'>static</font> <font color='#0000FF'>const</font> shared_ptr_thread_safe<font color='#5555FF'><</font>font<font color='#5555FF'>></font> <b><a name='get_font'></a>get_font</b><font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- returns an instance of this font.
throws
- std::bad_alloc
This exception is thrown if there is a problem gathering the needed
memory for the font object.
!*/</font>
<font color='#0000FF'>private</font>:
<font color='#009900'>// restricted functions
</font> <b><a name='default_font'></a>default_font</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#009900'>// normal constructor
</font> <b><a name='default_font'></a>default_font</b><font face='Lucida Console'>(</font>default_font<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// copy constructor
</font> default_font<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>default_font<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// assignment operator
</font> <b>}</b>;
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>class</font> <b><a name='bdf_font'></a>bdf_font</b> : <font color='#0000FF'>public</font> font
<b>{</b>
<font color='#009900'>/*!
WHAT THIS OBJECT REPRESENTS
This is a font object that is capable of loading of loading BDF (Glyph
Bitmap Distribution Format) font files.
THREAD SAFETY
If you only access this object via the functions in the parent class font
then this object is thread safe. But if you need to call any of the
functions introduced in this derived class then you need to serialize
access to this object while you call these functions.
!*/</font>
<font color='#0000FF'>public</font>:
<b><a name='bdf_font'></a>bdf_font</b><font face='Lucida Console'>(</font>
<font color='#0000FF'><u>long</u></font> default_char <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>1</font>
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- for all x:
- #has_character(x) == false
(i.e. this font starts out empty. You have to call read_bdf_file()
to load it with data)
- if (default_char == -1) then
- the letter returned by (*this)[ch] for values of
ch where has_character(ch) == false will be the
default glyph defined in the bdf file.
- else
- the letter returned by (*this)[ch] for values of
ch where has_character(ch) == false will be the
letter (*this)[default_char].
!*/</font>
<font color='#0000FF'><u>long</u></font> <b><a name='read_bdf_file'></a>read_bdf_file</b><font face='Lucida Console'>(</font>
std::istream<font color='#5555FF'>&</font> in,
unichar max_enc,
unichar min_enc <font color='#5555FF'>=</font> <font color='#979000'>0</font>
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- attempts to read the font data from the given input stream into
*this. The input stream is expected to contain a valid BDF file.
- reads in characters with encodings in the range min_enc to max_enc
into this font. All characters in the font file outside this range
are ignored.
- returns the number of characters loaded into this font from the
given input stream.
!*/</font>
<font color='#0000FF'><u>void</u></font> <b><a name='adjust_metrics'></a>adjust_metrics</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
ensures
- Computes metrics based on actual glyphs loaded, instead of using
the values in the bdf file header. (May be useful if loading glyphs
from more than one file or a small part of a file.)
!*/</font>
<font color='#0000FF'>private</font>:
<b><a name='bdf_font'></a>bdf_font</b><font face='Lucida Console'>(</font> bdf_font<font color='#5555FF'>&</font> <font face='Lucida Console'>)</font>; <font color='#009900'>// copy constructor
</font> bdf_font<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font> bdf_font<font color='#5555FF'>&</font> <font face='Lucida Console'>)</font>; <font color='#009900'>// assignment operator
</font>
<b>}</b>;
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>const</font> shared_ptr_thread_safe<font color='#5555FF'><</font>font<font color='#5555FF'>></font> <b><a name='get_native_font'></a>get_native_font</b><font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font>;
<font color='#009900'>/*!
requires
- DLIB_NO_GUI_SUPPORT is not defined
ensures
- returns a font object that uses the local font
!*/</font>
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>
<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_FONTs_ABSTRACT_
</font>
</pre></body></html> |