1 /* 2 * Copyright (C) 2025 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.graphics.pdf.component; 18 19 import android.annotation.FlaggedApi; 20 import android.annotation.NonNull; 21 import android.graphics.pdf.flags.Flags; 22 23 @FlaggedApi(Flags.FLAG_ENABLE_EDIT_PDF_TEXT_OBJECTS) 24 public class PdfPageTextObjectFont { 25 private @PdfPageTextObjectFontFamily.Type int mFontFamily; 26 private boolean mIsBold; 27 private boolean mIsItalic; 28 PdfPageTextObjectFont(@dfPageTextObjectFontFamily.Type int fontFamily, boolean isBold, boolean isItalic)29 public PdfPageTextObjectFont(@PdfPageTextObjectFontFamily.Type int fontFamily, 30 boolean isBold, boolean isItalic) { 31 mFontFamily = fontFamily; 32 mIsBold = isBold; 33 mIsItalic = isItalic; 34 } 35 PdfPageTextObjectFont(@onNull PdfPageTextObjectFont font)36 public PdfPageTextObjectFont(@NonNull PdfPageTextObjectFont font) { 37 this.mFontFamily = font.getFontFamily(); 38 this.mIsBold = font.isBold(); 39 this.mIsItalic = font.isItalic(); 40 } 41 42 /** 43 * Returns the font-family which is of type {@link PdfPageTextObjectFontFamily} 44 * 45 * @return The font-family. 46 */ getFontFamily()47 public @PdfPageTextObjectFontFamily.Type int getFontFamily() { 48 return mFontFamily; 49 } 50 51 /** 52 * Set the font family of the object. 53 * 54 * @param fontFamily The font family to be set. 55 */ setFontFamily(@dfPageTextObjectFontFamily.Type int fontFamily)56 public void setFontFamily(@PdfPageTextObjectFontFamily.Type int fontFamily) { 57 mFontFamily = fontFamily; 58 } 59 60 /** 61 * Determines if the text is bold. 62 * 63 * @return true if the text is bold, false otherwise. 64 */ isBold()65 public boolean isBold() { 66 return mIsBold; 67 } 68 69 /** 70 * Sets whether the text should be bold or not. 71 * 72 * @param bold true if the text should be bold, false otherwise. 73 */ setBold(boolean bold)74 public void setBold(boolean bold) { 75 mIsBold = bold; 76 } 77 78 /** 79 * Determines if the text is italic. 80 * 81 * @return true if the text is italic, false otherwise. 82 */ isItalic()83 public boolean isItalic() { 84 return mIsItalic; 85 } 86 87 /** 88 * Set whether the text should be italic or not. 89 * 90 * @param italic true if the text should be italic, false otherwise. 91 */ setItalic(boolean italic)92 public void setItalic(boolean italic) { 93 mIsItalic = italic; 94 } 95 } 96