إدارة الخطوط في العروض التقديمية على Android
Contents
[
Hide
]
إدارة الخصائص المتعلقة بالخط
عادةً ما تحتوي العروض التقديمية على كل من النصوص والصور. يمكن تنسيق النص بطرق مختلفة، إما لتسليط الضوء على أقسام وكلمات معينة أو للامتثال لأنماط الشركة. يساعد تنسيق النص المستخدمين على تغيير مظهر ومضمون محتوى العرض. يوضح هذا المقال كيفية استخدام Aspose.Slides for Android عبر Java لتكوين خصائص الخط للفقرة النصية على الشريحة.
لإدارة خصائص الخط لفقرة باستخدام Aspose.Slides for Android عبر Java:
- إنشاء كائن من الفئة Presentation.
- الحصول على مرجع الشريحة باستخدام الفهرس الخاص بها.
- الوصول إلى أشكال Placeholder في الشريحة وتحويلها إلى AutoShape.
- الحصول على الـ Paragraph من الـ TextFrame المعروض بواسطة AutoShape.
- محاذاة الفقرة.
- الوصول إلى نص الـ Paragraph عبر الـ Portion.
- تعريف الخط باستخدام FontData وتعيين Font للنص في الـ Portion وفقًا لذلك.
- جعل الخط غامقًا.
- جعل الخط مائلًا.
- تعيين لون الخط باستخدام FillFormat المعروض من كائن الـ Portion.
- حفظ العرض المعدل كملف PPTX.
التنفيذ للخطوات المذكورة موضح أدناه. يأخذ عرضًا غير مُنسيق ويُطبق تنسيقات الخط على إحدى الشرائح. توضح اللقطات التالية ملف الإدخال وكيفية تعديل الشيفرة له. تقوم الشيفرة بتغيير الخط، واللون، ونمط الخط.
![]() |
|---|
| الشكل: النص في ملف الإدخال |
![]() |
|---|
| الشكل: نفس النص مع تنسيق محدث |
// إنشاء كائن Presentation يمثل ملف PPTX
Presentation pres = new Presentation("FontProperties.pptx");
try {
// الوصول إلى شريحة باستخدام موضعها
ISlide slide = pres.getSlides().get_Item(0);
// الوصول إلى العنصر النائب الأول والثاني في الشريحة وتحويلهما إلى AutoShape
ITextFrame tf1 = ((IAutoShape) slide.getShapes().get_Item(0)).getTextFrame();
ITextFrame tf2 = ((IAutoShape) slide.getShapes().get_Item(1)).getTextFrame();
// الوصول إلى الفقرة الأولى
IParagraph para1 = tf1.getParagraphs().get_Item(0);
IParagraph para2 = tf2.getParagraphs().get_Item(0);
// محاذاة الفقرة
para2.getParagraphFormat().setAlignment(TextAlignment.JustifyLow);
// الوصول إلى الجزء الأول
IPortion port1 = para1.getPortions().get_Item(0);
IPortion port2 = para2.getPortions().get_Item(0);
// تعريف خطوط جديدة
FontData fd1 = new FontData("Elephant");
FontData fd2 = new FontData("Castellar");
// تعيين خطوط جديدة إلى الجزء
port1.getPortionFormat().setLatinFont(fd1);
port2.getPortionFormat().setLatinFont(fd2);
// تعيين الخط إلى غامق
port1.getPortionFormat().setFontBold(NullableBool.True);
port2.getPortionFormat().setFontBold(NullableBool.True);
// تعيين الخط إلى مائل
port1.getPortionFormat().setFontItalic(NullableBool.True);
port2.getPortionFormat().setFontItalic(NullableBool.True);
// تعيين لون الخط
port1.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port1.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
port2.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port2.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GREEN);
// حفظ ملف PPTX إلى القرص
pres.save("WelcomeFont.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
تعيين خصائص خط النص
كما هو مذكور في إدارة الخصائص المتعلقة بالخط، يُستخدم الـ Portion لحفظ النص الذي له نمط تنسيق مشابه داخل الفقرة. يوضح هذا المقال كيفية استخدام Aspose.Slides for Android عبر Java لإنشاء مربع نص يحتوي على بعض النصوص ثم تعريف خط معين، والخصائص الأخرى لفئة عائلة الخط.
لإنشاء مربع نص وتعيين خصائص الخط للنص داخلها:
- إنشاء كائن من الفئة Presentation.
- الحصول على مرجع شريحة باستخدام الفهرس الخاص بها.
- إضافة AutoShape من النوع Rectangle إلى الشريحة.
- إزالة نمط التعبئة المرتبط بالـ AutoShape.
- الوصول إلى الـ TextFrame الخاص بالـ AutoShape.
- إضافة بعض النص إلى الـ TextFrame.
- الوصول إلى كائن الـ Portion المرتبط بالـ TextFrame.
- تعريف الخط الذي سيُستخدم للـ Portion.
- تعيين خصائص أخرى للخط مثل الغامق، المائل، تحت الخط، اللون والارتفاع باستخدام الخصائص المتاحة في كائن الـ Portion.
- كتابة العرض المعدل كملف PPTX.
التنفيذ للخطوات المذكورة موضح أدناه.
![]() |
|---|
| الشكل: نص مع بعض خصائص الخط التي تم تعيينها بواسطة Aspose.Slides for Android عبر Java |
// إنشاء كائن Presentation يمثل ملف PPTX
Presentation pres = new Presentation();
try {
// الحصول على الشريحة الأولى
ISlide sld = pres.getSlides().get_Item(0);
// إضافة AutoShape من نوع Rectangle
IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 200, 50);
// إزالة أي نمط تعبئة مرتبط بـ AutoShape
ashp.getFillFormat().setFillType(FillType.NoFill);
// الوصول إلى TextFrame المرتبط بـ AutoShape
ITextFrame tf = ashp.getTextFrame();
tf.setText("Aspose TextBox");
// الوصول إلى Portion المرتبط بـ TextFrame
IPortion port = tf.getParagraphs().get_Item(0).getPortions().get_Item(0);
// تعيين الخط للـ Portion
port.getPortionFormat().setLatinFont(new FontData("Times New Roman"));
// تعيين الخط إلى غامق
port.getPortionFormat().setFontBold(NullableBool.True);
// تعيين الخط إلى مائل
port.getPortionFormat().setFontItalic(NullableBool.True);
// تعيين الخط إلى مسطر
port.getPortionFormat().setFontUnderline(TextUnderlineType.Single);
// تعيين ارتفاع الخط
port.getPortionFormat().setFontHeight(25);
// تعيين لون الخط
port.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
port.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
// حفظ العرض إلى القرص
pres.save("pptxFont.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}


