File size: 80,248 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 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
<html><!-- Created using the cpp_pretty_printer from the dlib C++ library. See http://dlib.net for updates. --><head><title>dlib C++ Library - fonts.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2005 Davis E. King ([email protected]), and Nils Labugt, Keita Mochizuki
</font><font color='#009900'>// License: Boost Software License See LICENSE.txt for the full license.
</font>
<font color='#0000FF'>#ifndef</font> DLIB_FONTs_
<font color='#0000FF'>#define</font> DLIB_FONTs_
<font color='#0000FF'>#include</font> <font color='#5555FF'><</font>memory<font color='#5555FF'>></font>
<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='fonts_abstract.h.html'>fonts_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../algs.h.html'>../algs.h</a>"
<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> "<a style='text-decoration:none' href='../array.h.html'>../array.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../array2d.h.html'>../array2d.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../threads.h.html'>../threads.h</a>"
<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'>/*!
INITIAL VALUE
- defined by constructor
CONVENTION
- if (points != 0) then
- points == an array of count point structs
- w == width()
- count == num_of_points()
!*/</font>
<font color='#0000FF'>public</font>:
<font color='#0000FF'>struct</font> <b><a name='point'></a>point</b>
<b>{</b>
<b><a name='point'></a>point</b> <font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><b>{</b><b>}</b>
<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> :
x<font face='Lucida Console'>(</font>x_<font face='Lucida Console'>)</font>,
y<font face='Lucida Console'>(</font>y_<font face='Lucida Console'>)</font>
<b>{</b><b>}</b>
<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>;
<b><a name='letter'></a>letter</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font> :
points<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,
w<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,
count<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>
<b>{</b><b>}</b>
<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> :
points<font face='Lucida Console'>(</font><font color='#0000FF'>new</font> point[point_count]<font face='Lucida Console'>)</font>,
w<font face='Lucida Console'>(</font>width_<font face='Lucida Console'>)</font>,
count<font face='Lucida Console'>(</font>point_count<font face='Lucida Console'>)</font>
<b>{</b><b>}</b>
~<b><a name='letter'></a>letter</b><font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>points<font face='Lucida Console'>)</font>
<font color='#0000FF'>delete</font> [] points;
<b>}</b>
<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> <b>{</b> <font color='#0000FF'>return</font> w; <b>}</b>
<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> <b>{</b> <font color='#0000FF'>return</font> count;<b>}</b>
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>
<b>{</b>
<font color='#BB00BB'>DLIB_ASSERT</font> <font face='Lucida Console'>(</font>i <font color='#5555FF'><</font> <font color='#BB00BB'>num_of_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
"<font color='#CC0000'>\tvoid letter::operator[]()</font>"
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\ti: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> i
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tnum_of_points(): </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font color='#BB00BB'>num_of_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>;
<font color='#0000FF'>return</font> points[i];
<b>}</b>
<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>
<b>{</b>
<font color='#BB00BB'>DLIB_ASSERT</font> <font face='Lucida Console'>(</font>i <font color='#5555FF'><</font> <font color='#BB00BB'>num_of_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
"<font color='#CC0000'>\tvoid letter::operator[]()</font>"
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\ti: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> i
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tnum_of_points(): </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font color='#BB00BB'>num_of_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>;
<font color='#0000FF'>return</font> points[i];
<b>}</b>
<font color='#0000FF'>friend</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='#0000FF'>friend</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='#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>
<b>{</b>
<font color='#BB00BB'>exchange</font><font face='Lucida Console'>(</font>points, item.points<font face='Lucida Console'>)</font>;
<font color='#BB00BB'>exchange</font><font face='Lucida Console'>(</font>w, item.w<font face='Lucida Console'>)</font>;
<font color='#BB00BB'>exchange</font><font face='Lucida Console'>(</font>count, item.count<font face='Lucida Console'>)</font>;
<b>}</b>
<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>
point<font color='#5555FF'>*</font> points;
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> w;
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> count;
<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'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>class</font> <b><a name='font'></a>font</b>
<b>{</b>
<font color='#0000FF'>public</font>:
<font color='#0000FF'>virtual</font> ~<b><a name='font'></a>font</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <b>{</b><b>}</b>
<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='#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='#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='#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='#0000FF'>virtual</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='#0000FF'>virtual</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='#0000FF'>virtual</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='#0000FF'>virtual</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'>// ------------------------------------------------------------------------------------
</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> <font face='Lucida Console'>(</font>std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::npos<font face='Lucida Console'>)</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
<b>{</b>
<font color='#0000FF'>typedef</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font> string;
<font color='#BB00BB'>DLIB_ASSERT</font> <font face='Lucida Console'>(</font> <font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font face='Lucida Console'>(</font>first <font color='#5555FF'><</font><font color='#5555FF'>=</font> last <font color='#5555FF'>&</font><font color='#5555FF'>&</font> last <font color='#5555FF'><</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> ,
"<font color='#CC0000'>\tvoid font::compute_size()</font>"
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tlast == string::npos: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font>?"<font color='#CC0000'>true</font>":"<font color='#CC0000'>false</font>"<font face='Lucida Console'>)</font>
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tfirst: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>first
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tlast: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>last
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tstr.size(): </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>;
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> line_width <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> newlines <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
width <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
height <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font>
last <font color='#5555FF'>=</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font>;
<font color='#0000FF'>const</font> font<font color='#5555FF'>&</font> f <font color='#5555FF'>=</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'>typename</font> string::size_type i <font color='#5555FF'>=</font> first; i <font color='#5555FF'><</font><font color='#5555FF'>=</font> last; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#009900'>// ignore '\r' characters
</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str[i] <font color='#5555FF'>=</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\r</font>'<font face='Lucida Console'>)</font>
<font color='#0000FF'>continue</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str[i] <font color='#5555FF'>=</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\n</font>'<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#5555FF'>+</font><font color='#5555FF'>+</font>newlines;
width <font color='#5555FF'>=</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font>width,line_width<font face='Lucida Console'>)</font>;
line_width <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<b>}</b>
<font color='#0000FF'>else</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>is_combining_char</font><font face='Lucida Console'>(</font>str[i]<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>
line_width <font color='#5555FF'>+</font><font color='#5555FF'>=</font> f[str[i]].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<b>}</b>
<b>}</b>
width <font color='#5555FF'>=</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font>width,line_width<font face='Lucida Console'>)</font>;
height <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>newlines<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>f.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
width <font color='#5555FF'>+</font><font color='#5555FF'>=</font> f.<font color='#BB00BB'>left_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> f.<font color='#BB00BB'>right_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<b>}</b>
<b>}</b>
<font color='#009900'>// ------------------------------------------------------------------------------------
</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='#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> <font face='Lucida Console'>(</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> rectangle area_ <font color='#5555FF'>=</font> <font color='#BB00BB'>rectangle</font><font face='Lucida Console'>(</font>std::numeric_limits<font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font>::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, std::numeric_limits<font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font>::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
std::numeric_limits<font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font>::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, std::numeric_limits<font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font>::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
<b>{</b>
<font color='#0000FF'>typedef</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font> string;
<font color='#BB00BB'>DLIB_ASSERT</font> <font face='Lucida Console'>(</font> <font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font face='Lucida Console'>(</font>first <font color='#5555FF'><</font><font color='#5555FF'>=</font> last <font color='#5555FF'>&</font><font color='#5555FF'>&</font> last <font color='#5555FF'><</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> ,
"<font color='#CC0000'>\tvoid font::draw_string()</font>"
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tlast == string::npos: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font>?"<font color='#CC0000'>true</font>":"<font color='#CC0000'>false</font>"<font face='Lucida Console'>)</font>
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tfirst: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>first
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tlast: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>last
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tstr.size(): </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>;
rectangle area <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font>c<font face='Lucida Console'>)</font>.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font>area_<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>area.<font color='#BB00BB'>is_empty</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>return</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font>
last <font color='#5555FF'>=</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font>;
<font color='#0000FF'>const</font> font<font color='#5555FF'>&</font> f <font color='#5555FF'>=</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
<font color='#0000FF'><u>long</u></font> y_offset <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> f.<font color='#BB00BB'>ascender</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> <font color='#979000'>1</font>;
<font color='#0000FF'><u>long</u></font> pos <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font>f.<font color='#BB00BB'>left_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'>typename</font> string::size_type i <font color='#5555FF'>=</font> first; i <font color='#5555FF'><</font><font color='#5555FF'>=</font> last; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#009900'>// ignore the '\r' character
</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str[i] <font color='#5555FF'>=</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\r</font>'<font face='Lucida Console'>)</font>
<font color='#0000FF'>continue</font>;
<font color='#009900'>// A combining character should be applied to the previous character, and we
</font> <font color='#009900'>// therefore make one step back. If a combining comes right after a newline,
</font> <font color='#009900'>// then there must be some kind of error in the string, and we don't combine.
</font> <font color='#0000FF'>if</font><font face='Lucida Console'>(</font><font color='#BB00BB'>is_combining_char</font><font face='Lucida Console'>(</font>str[i]<font face='Lucida Console'>)</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font>
pos <font color='#5555FF'>></font> rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font><font face='Lucida Console'>(</font>f.<font color='#BB00BB'>left_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
<b>{</b>
pos <font color='#5555FF'>-</font><font color='#5555FF'>=</font> f[str[i]].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str[i] <font color='#5555FF'>=</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\n</font>'<font face='Lucida Console'>)</font>
<b>{</b>
y_offset <font color='#5555FF'>+</font><font color='#5555FF'>=</font> f.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
pos <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font>f.<font color='#BB00BB'>left_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>continue</font>;
<b>}</b>
<font color='#009900'>// only look at letters in the intersection area
</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>area.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font><font face='Lucida Console'>(</font>f.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'><</font> y_offset<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#009900'>// the string is now below our rectangle so we are done
</font> <font color='#0000FF'>break</font>;
<b>}</b>
<font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>area.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>></font> pos <font color='#5555FF'>-</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font><font face='Lucida Console'>(</font>f.<font color='#BB00BB'>left_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font>
pos <font color='#5555FF'>+</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font><font face='Lucida Console'>(</font>f[str[i]].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> f.<font color='#BB00BB'>right_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'><</font> area.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>
<b>{</b>
pos <font color='#5555FF'>+</font><font color='#5555FF'>=</font> f[str[i]].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>continue</font>;
<b>}</b>
<font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>area.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font><font face='Lucida Console'>(</font>f.<font color='#BB00BB'>right_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'><</font> pos<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#009900'>// keep looking because there might be a '\n' in the string that
</font> <font color='#009900'>// will wrap us around and put us back into our rectangle.
</font> <font color='#0000FF'>continue</font>;
<b>}</b>
<font color='#009900'>// at this point in the loop we know that f[str[i]] overlaps
</font> <font color='#009900'>// horizontally with the intersection rectangle area.
</font>
<font color='#0000FF'>const</font> letter<font color='#5555FF'>&</font> l <font color='#5555FF'>=</font> f[str[i]];
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>short</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'><</font> l.<font color='#BB00BB'>num_of_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> x <font color='#5555FF'>=</font> l[i].x <font color='#5555FF'>+</font> pos;
<font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> y <font color='#5555FF'>=</font> l[i].y <font color='#5555FF'>+</font> y_offset;
<font color='#009900'>// draw each pixel of the letter if it is inside the intersection
</font> <font color='#009900'>// rectangle
</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>area.<font color='#BB00BB'>contains</font><font face='Lucida Console'>(</font>x,y<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
<b>{</b>
<font color='#BB00BB'>assign_pixel</font><font face='Lucida Console'>(</font>c[y<font color='#5555FF'>-</font>c.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>][x<font color='#5555FF'>-</font>c.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>], color<font face='Lucida Console'>)</font>;
<b>}</b>
<b>}</b>
pos <font color='#5555FF'>+</font><font color='#5555FF'>=</font> l.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<b>}</b>
<b>}</b>
<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='#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 face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
<b>{</b>
<font color='#BB00BB'>draw_string</font><font face='Lucida Console'>(</font>c,rect, str, <font color='#979000'>0</font>, <font color='#979000'>0</font>, <font face='Lucida Console'>(</font>std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::npos<font face='Lucida Console'>)</font>,
<font color='#BB00BB'>rectangle</font><font face='Lucida Console'>(</font>std::numeric_limits<font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font>::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, std::numeric_limits<font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font>::<font color='#BB00BB'>min</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
std::numeric_limits<font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font>::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, std::numeric_limits<font color='#5555FF'><</font><font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font>::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#009900'>// ------------------------------------------------------------------------------------
</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> <font face='Lucida Console'>(</font>std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::npos<font face='Lucida Console'>)</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
<b>{</b>
<font color='#0000FF'>typedef</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font> string;
<font color='#BB00BB'>DLIB_ASSERT</font> <font face='Lucida Console'>(</font> <font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font face='Lucida Console'>(</font>first <font color='#5555FF'><</font><font color='#5555FF'>=</font> last <font color='#5555FF'>&</font><font color='#5555FF'>&</font> last <font color='#5555FF'><</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> ,
"<font color='#CC0000'>\trectangle font::compute_cursor_rect()</font>"
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tlast == string::npos: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font>?"<font color='#CC0000'>true</font>":"<font color='#CC0000'>false</font>"<font face='Lucida Console'>)</font>
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tfirst: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>first
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tlast: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>last
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tindex: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> index
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tstr.size(): </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>;
<font color='#0000FF'>const</font> font<font color='#5555FF'>&</font> f <font color='#5555FF'>=</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font>
last <font color='#5555FF'>=</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font>;
<font color='#0000FF'><u>long</u></font> x <font color='#5555FF'>=</font> f.<font color='#BB00BB'>left_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'><u>long</u></font> y <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#0000FF'><u>int</u></font> count <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'>typename</font> string::size_type i <font color='#5555FF'>=</font> first; i <font color='#5555FF'><</font><font color='#5555FF'>=</font> last <font color='#5555FF'>&</font><font color='#5555FF'>&</font> i <font color='#5555FF'><</font> index; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#5555FF'>+</font><font color='#5555FF'>+</font>count;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str[i] <font color='#5555FF'>=</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\n</font>'<font face='Lucida Console'>)</font>
<b>{</b>
x <font color='#5555FF'>=</font> f.<font color='#BB00BB'>left_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
y <font color='#5555FF'>+</font><font color='#5555FF'>=</font> f.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
count <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<b>}</b>
<font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>is_combining_char</font><font face='Lucida Console'>(</font>str[i]<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font>
str[i] <font color='#5555FF'>!</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\r</font>'<font face='Lucida Console'>)</font>
<b>{</b>
x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> f[str[i]].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<b>}</b>
<b>}</b>
<b>}</b>
x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
y <font color='#5555FF'>+</font><font color='#5555FF'>=</font> rect.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#009900'>// if the cursor is at the start of a line then back it up one pixel
</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>count <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
<font color='#5555FF'>-</font><font color='#5555FF'>-</font>x;
<font color='#0000FF'>return</font> <font color='#BB00BB'>rectangle</font><font face='Lucida Console'>(</font>x,y,x,y<font color='#5555FF'>+</font>f.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#009900'>// ------------------------------------------------------------------------------------
</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>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> <font face='Lucida Console'>(</font>std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font>::npos<font face='Lucida Console'>)</font>
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
<b>{</b>
<font color='#0000FF'>typedef</font> std::basic_string<font color='#5555FF'><</font>T,traits,alloc<font color='#5555FF'>></font> string;
<font color='#BB00BB'>DLIB_ASSERT</font> <font face='Lucida Console'>(</font> <font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font face='Lucida Console'>(</font>first <font color='#5555FF'><</font><font color='#5555FF'>=</font> last <font color='#5555FF'>&</font><font color='#5555FF'>&</font> last <font color='#5555FF'><</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> ,
"<font color='#CC0000'>\tunsigned long font::compute_cursor_pos()</font>"
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tlast == string::npos: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font>?"<font color='#CC0000'>true</font>":"<font color='#CC0000'>false</font>"<font face='Lucida Console'>)</font>
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tfirst: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>first
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tlast: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>last
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tx: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> x
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\ty: </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> y
<font color='#5555FF'><</font><font color='#5555FF'><</font> "<font color='#CC0000'>\n\tstr.size(): </font>" <font color='#5555FF'><</font><font color='#5555FF'><</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>;
<font color='#0000FF'>const</font> font<font color='#5555FF'>&</font> f <font color='#5555FF'>=</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>return</font> <font color='#979000'>0</font>;
<font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>first <font color='#5555FF'>></font><font color='#5555FF'>=</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>return</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'><</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font><font face='Lucida Console'>(</font>str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
y <font color='#5555FF'>-</font><font color='#5555FF'>=</font> rect.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
x <font color='#5555FF'>-</font><font color='#5555FF'>=</font> rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>y <font color='#5555FF'><</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
y <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>x <font color='#5555FF'><</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
x <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>last <font color='#5555FF'>=</font><font color='#5555FF'>=</font> string::npos<font face='Lucida Console'>)</font>
last <font color='#5555FF'>=</font> str.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font>;
<font color='#009900'>// first figure out what line we are on
</font> <font color='#0000FF'>typename</font> string::size_type pos <font color='#5555FF'>=</font> first;
<font color='#0000FF'><u>long</u></font> line <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
<font color='#0000FF'>while</font> <font face='Lucida Console'>(</font><font color='#0000FF'>static_cast</font><font color='#5555FF'><</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font><font face='Lucida Console'>(</font>y<font face='Lucida Console'>)</font> <font color='#5555FF'>></font><font color='#5555FF'>=</font> f.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
<b>{</b>
<font color='#5555FF'>+</font><font color='#5555FF'>+</font>line;
y <font color='#5555FF'>-</font><font color='#5555FF'>=</font> f.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#009900'>// find the start of the given line
</font> <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'>typename</font> string::size_type i <font color='#5555FF'>=</font> first; i <font color='#5555FF'><</font><font color='#5555FF'>=</font> last <font color='#5555FF'>&</font><font color='#5555FF'>&</font> line <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>str[i] <font color='#5555FF'>=</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\n</font>'<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#5555FF'>-</font><font color='#5555FF'>-</font>line;
pos <font color='#5555FF'>=</font> i <font color='#5555FF'>+</font> <font color='#979000'>1</font>;
<b>}</b>
<b>}</b>
<font color='#009900'>// now str[pos] == the first character of the start of the line
</font> <font color='#009900'>// that contains the cursor.
</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> string::size_type start_of_line <font color='#5555FF'>=</font> pos;
<font color='#0000FF'><u>long</u></font> cur_x <font color='#5555FF'>=</font> f.<font color='#BB00BB'>left_overflow</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#009900'>// set the current cursor position to where the mouse clicked
</font> <font color='#0000FF'>while</font> <font face='Lucida Console'>(</font>pos <font color='#5555FF'><</font><font color='#5555FF'>=</font> last<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>x <font color='#5555FF'><</font><font color='#5555FF'>=</font> cur_x <font color='#5555FF'>|</font><font color='#5555FF'>|</font> str[pos] <font color='#5555FF'>=</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\n</font>'<font face='Lucida Console'>)</font>
<font color='#0000FF'>break</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>is_combining_char</font><font face='Lucida Console'>(</font>str[pos]<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font>
str[pos] <font color='#5555FF'>!</font><font color='#5555FF'>=</font> '<font color='#FF0000'>\r</font>'<font face='Lucida Console'>)</font>
<b>{</b>
cur_x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> f[str[pos]].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<b>}</b>
<font color='#5555FF'>+</font><font color='#5555FF'>+</font>pos;
<b>}</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>x <font color='#5555FF'><</font><font color='#5555FF'>=</font> cur_x<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>pos <font color='#5555FF'>!</font><font color='#5555FF'>=</font> start_of_line<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#009900'>// we might actually be closer to the previous character
</font> <font color='#009900'>// so check for that and if so then jump us back one.
</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> width <font color='#5555FF'>=</font> f[str[pos<font color='#5555FF'>-</font><font color='#979000'>1</font>]].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>x <font color='#5555FF'><</font> cur_x <font color='#5555FF'>-</font> width<font color='#5555FF'>/</font><font color='#979000'>2</font><font face='Lucida Console'>)</font>
<font color='#5555FF'>-</font><font color='#5555FF'>-</font>pos;
<b>}</b>
<b>}</b>
<font color='#0000FF'>return</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'><</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>></font><font face='Lucida Console'>(</font>pos<font face='Lucida Console'>)</font>;
<b>}</b>
<b>}</b>;
<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>const</font> std::shared_ptr<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'>// ----------------------------------------------------------------------------------------
</font>
<font color='#0000FF'>class</font> <b><a name='default_font'></a>default_font</b> : <font color='#0000FF'>public</font> font
<b>{</b>
letter<font color='#5555FF'>*</font> l;
<b><a name='default_font'></a>default_font</b><font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</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>
<font color='#0000FF'>public</font>:
<font color='#0000FF'>static</font> <font color='#0000FF'>const</font> std::shared_ptr<font color='#5555FF'><</font>font<font color='#5555FF'>></font><font color='#5555FF'>&</font> <b><a name='get_font'></a>get_font</b> <font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>static</font> mutex m;
<font color='#0000FF'>static</font> std::shared_ptr<font color='#5555FF'><</font>font<font color='#5555FF'>></font> f;
auto_mutex <font color='#BB00BB'>M</font><font face='Lucida Console'>(</font>m<font face='Lucida Console'>)</font>;
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>f.<font color='#BB00BB'>get</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
f.<font color='#BB00BB'>reset</font><font face='Lucida Console'>(</font><font color='#0000FF'>new</font> default_font<font face='Lucida Console'>)</font>;
<font color='#0000FF'>return</font> f;
<b>}</b>
~<b><a name='default_font'></a>default_font</b><font face='Lucida Console'>(</font>
<font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>delete</font> [] l;
<b>}</b>
<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> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>16</font>; <b>}</b>
<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> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>12</font>; <b>}</b>
<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> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>1</font>; <b>}</b>
<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> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>2</font>; <b>}</b>
<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>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>ch <font color='#5555FF'><</font> <font color='#979000'>256</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font> <font face='Lucida Console'>(</font>l[ch].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> l[ch].<font color='#BB00BB'>num_of_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>return</font> <font color='#979000'>true</font>;
<font color='#0000FF'>else</font>
<font color='#0000FF'>return</font> <font color='#979000'>false</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>
unichar ch
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
<b>{</b>
<font color='#0000FF'>if</font><font face='Lucida Console'>(</font>ch <font color='#5555FF'><</font> <font color='#979000'>256</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>return</font> l[ch];
<font color='#0000FF'>return</font> l[<font color='#979000'>0</font>]; <font color='#009900'>// just return one of the empty characters in this case
</font> <b>}</b>
<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='#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='#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='#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>
<b>{</b>
<font color='#0000FF'>return</font> fbb.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
<b>}</b>
<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>
<b>{</b>
<font color='#0000FF'>return</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font> <font color='#979000'>0</font>L, <font color='#979000'>1</font> <font color='#5555FF'>-</font> fbb.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>;
<b>}</b>
<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>
<b>{</b>
<font color='#0000FF'>return</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font> <font color='#979000'>0</font>L, <font color='#5555FF'>-</font>fbb.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>;
<b>}</b>
<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>
<b>{</b>
<font color='#0000FF'>return</font> right_overflow_;
<b>}</b>
<font color='#0000FF'>const</font> letter<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b>[] <font face='Lucida Console'>(</font> unichar uch <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font> <font color='#5555FF'>!</font><font color='#BB00BB'>has_character</font><font face='Lucida Console'>(</font>uch<font face='Lucida Console'>)</font> <font face='Lucida Console'>)</font>
<b>{</b>
<font color='#0000FF'>return</font> gl[default_char];
<b>}</b>
<font color='#0000FF'>return</font> gl[uch];
<b>}</b>
<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>
<b>{</b>
<font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>ch <font color='#5555FF'><</font> gl.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&</font><font color='#5555FF'>&</font> <font face='Lucida Console'>(</font>gl[ch].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> gl[ch].<font color='#BB00BB'>num_of_points</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
<font color='#0000FF'>return</font> <font color='#979000'>true</font>;
<font color='#0000FF'>else</font>
<font color='#0000FF'>return</font> <font color='#979000'>false</font>;
<b>}</b>
<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='#0000FF'>private</font>:
<font color='#0000FF'><u>bool</u></font> <b><a name='bitmap_to_letter'></a>bitmap_to_letter</b><font face='Lucida Console'>(</font> array2d<font color='#5555FF'><</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>></font><font color='#5555FF'>&</font> bitmap, unichar enc, <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> width, <font color='#0000FF'><u>int</u></font> x_offset, <font color='#0000FF'><u>int</u></font> y_offset <font face='Lucida Console'>)</font>;
array<font color='#5555FF'><</font>letter<font color='#5555FF'>></font> gl;
unichar default_char; <font color='#009900'>// if (is_intialized == true), then this MUST be an actual glyph
</font> <font color='#0000FF'><u>bool</u></font> is_initialized;
rectangle fbb;
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> right_overflow_;
<font color='#0000FF'><u>unsigned</u></font> global_width;
<font color='#0000FF'><u>bool</u></font> has_global_width;
<font color='#0000FF'><u>long</u></font> specified_default_char;
<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>
<b>}</b>
<font color='#0000FF'>#ifdef</font> NO_MAKEFILE
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='fonts.cpp.html'>fonts.cpp</a>"
<font color='#0000FF'>#endif</font>
<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_FONTs_
</font>
</pre></body></html> |